<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><span style="font-size: 14px;" class="">Haravikk-</span></div><div class=""><span style="font-size: 14px;" class=""><br class=""></span></div><div class=""><span style="font-size: 14px;" class="">Retaining the use of the binary operator using Void as the open end, certainly helps with readability. As I said in my initial comments, though, my gut is that these operators obfuscate the language. (i.e., it triggers the uninitiated to refer to the Swift documentation)</span></div><div class=""><span style="font-size: 14px;" class=""><br class=""></span></div><div class=""><span style="font-size: 14px;" class="">With that said, short of going with something akin to </span><span class="" style="font-size: 14px; color: rgb(36, 41, 46); font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; background-color: rgb(246, 248, 250);"> s[</span><span class="pl-c1" style="font-size: 14px; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; background-color: rgb(246, 248, 250); box-sizing: border-box; color: rgb(0, 134, 179);">first</span><span class="pl-k" style="font-size: 14px; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; background-color: rgb(246, 248, 250); box-sizing: border-box; color: rgb(167, 29, 93);">..<</span><span class="" style="background-color: rgb(246, 248, 250);"><font color="#24292e" face="SFMono-Regular, Consolas, Liberation Mono, Menlo, Courier, monospace" class=""><span style="font-size: 14px;" class="">i] </span></font></span><span style="font-size: 14px;" class="">and </span><span class="" style="font-size: 14px; color: rgb(36, 41, 46); font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; background-color: rgb(246, 248, 250);">s[i</span><font color="#a71d5d" face="SF Mono" class="" style="font-size: 14px;"><span class="" style="background-color: rgb(246, 248, 250);">..<</span></font><font color="#0086b3" face="SF Mono" class="" style="font-size: 14px;"><span class="" style="background-color: rgb(246, 248, 250);">last</span></font><span class="" style="font-size: 14px; color: rgb(36, 41, 46); font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; background-color: rgb(246, 248, 250);">] </span><span style="font-size: 14px;" class="">, I don’t know how we can make it intuitive. Obviously, the first/last approach is pretty darn verbose, so it doesn’t do anything to address the initial concern about </span><span class="" style="font-size: 14px; color: rgb(36, 41, 46); font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; background-color: rgb(246, 248, 250);"> s.</span><span class="pl-c1" style="font-size: 14px; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; background-color: rgb(246, 248, 250); box-sizing: border-box; color: rgb(0, 134, 179);">startIndex </span><span style="font-size: 14px;" class=""> </span><span style="font-size: 14px;" class="">being tiresome to write.</span></div><div class=""><span style="font-size: 14px;" class=""><br class=""></span></div><div class=""><span style="font-size: 14px;" class="">As you point out, underscore does does have a nice consistency within the language. It also kind of looks like “open” to me.</span></div><div class=""><span style="font-size: 14px;" class=""><br class=""></span></div><div class=""><span style="font-size: 14px;" class="">Thanks.</span></div><div class=""><span style="font-size: 14px;" class=""><br class=""></span></div><div class=""><span style="font-size: 14px;" class="">-Matt</span></div><div class=""><span style="font-size: 14px;" class=""><br class=""></span></div><div><blockquote type="cite" class=""><div class="">On Apr 18, 2017, at 4:08 PM, Haravikk <<a href="mailto:swift-evolution@haravikk.me" class="">swift-evolution@haravikk.me</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 18 Apr 2017, at 15:29, Matt Lewin via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><span style="font-size: 14px;" class=""><br class=""></span></div><div class=""><span style="font-size: 14px;" class="">In contrast, the proposed solution of </span></div><div class=""><pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; color: rgb(36, 41, 46);" class=""><span style="font-size: 14px;" class=""><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">//</span> half-open right-handed range</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> greeting <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> s[<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">..<</span>i]
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">//</span> closed right-handed range</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> withComma <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> s[<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">...</span><span class="pl-smi" style="box-sizing: border-box; color: rgb(51, 51, 51);">i</span>]
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="pl-c" style="box-sizing: border-box;">//</span> left-handed range (no need for half-open variant)</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> location <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> s[i<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">...</span>]</span></pre><div class=""><span style="font-size: 14px;" class="">requires both the code-writer and the code-reader to infer the missing side is the start or end.</span></div></div><div class=""><span style="font-size: 14px;" class=""><br class=""></span></div><div class=""><span style="font-size: 14px;" class="">From my perspective, this obfuscates the language by reducing the ability of the code to be read as English. (One of the goals of Swift design, correct?)</span></div></div></div></blockquote><br class=""></div><div class="">I mentioned in an earlier reply that my preference would be to retain use of the binary operator and use Void as the open end like so:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><span style="font-family: Monaco;" class="">func ... <T:Comparable>(lhs:T, rhs:Void) -> PartialRangeFrom<T> { … }</span></div><div class=""><font face="Monaco" class="">func ... <T:Comparable>(lhs:Void, rhs:T) -> PartialRangeTo<T> { … }</font></div><div class=""><font face="Monaco" class=""><br class=""></font></div><div class=""><font face="Monaco" class="">let rangeFrom = 5...()</font></div><div class=""><font face="Monaco" class="">let rangeTo = ()...5</font></div><div class=""><font face="Monaco" class=""><br class=""></font></div></blockquote>Would that solve your concern? Ideally we could also push for underscore to become another alias for Void when used in such a context, so we could do:<div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div class=""><font face="Monaco" class="">let rangeFrom = 5..._</font></div></div><div class=""><div class=""><font face="Monaco" class="">let rangeTo = _...5</font></div></div><div class=""><font face="Monaco" class=""><br class=""></font></div></blockquote>This to me is a bit more explicit that one end of the range being left open on purpose. I initially considered some kind of other symbol, but I think Void/underscore is suitable enough, underscore especially as it's consistent with other features.</div></div></blockquote></div><br class=""></body></html>