<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 22, 2017 at 6:40 PM, Chris Lattner via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Jan 20, 2017, at 9:39 PM, Brent Royal-Gordon via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
><br>
>> On Jan 20, 2017, at 2:45 PM, Dave Abrahams via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
>><br>
>> on Fri Jan 20 2017, Joe Groff <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
>><br>
>>> Jordan points out that the generalized slicing syntax stomps on '...x'<br>
>>> and 'x...', which would be somewhat obvious candidates for variadic<br>
>>> splatting if that ever becomes a thing. Now, variadics are a much more<br>
>>> esoteric feature and slicing is much more important to day-to-day<br>
>>> programming, so this isn't the end of the world IMO, but it is<br>
>>> something we'd be giving up.<br>
>><br>
>> Good point, Jordan.<br>
><br>
> In my experiments with introducing one-sided operators in Swift 3, I was not able to find a case where you actually wanted to write `c[i...]`. Everything I tried needed to use `c[i..<]` instead. My conclusion was that there was no possible use for postfix `...`; after all, `c[i...]` means `c[i...c.endIndex]`, which means `c[i..<c.index(after: c.endIndex)]`, which violates a precondition on `index(after:)`.<br>
<br>
</span>Right, the only sensible semantics for a one sided range with an open end point is that it goes to the end of the collection. I see a few different potential colors to paint this bikeshed with, all of which would have the semantics “c[i..<c.endIndex]”:<br>
<br>
1) Provide "c[i...]":<br>
2) Provide "c[i..<]":<br>
3) Provide both "c[i..<]” and "c[i…]":<br>
<br>
Since all of these operations would have the same behavior, it comes down to subjective questions:<br>
<br>
a) Do we want redundancy? IMO, no, which is why #3 is not very desirable.<br>
b) Which is easier to explain to people? As you say, "i..< is shorthand for i..<endindex” is nice and simple, which leans towards #2.<br>
c) Which is subjectively nicer looking? IMO, #1 is much nicer typographically. The ..< formulation looks like symbol soup, particularly because most folks would not put a space before ].<br>
<br>
There is no obvious winner, but to me, I tend to prefer #1. What do other folks think?<br></blockquote><div><br></div><div>I strongly prefer “c[i...]”</div><div><br></div><div>Nevin</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
> If that's the case, you can reserve postfix `...` for future variadics features, while using prefix `...` for these one-sided ranges.<br>
<br>
</span>I’m personally not very worried about this, the feature doesn’t exist yet and there are lots of ways to spell it. This is something that could and probably should deserve a more explicit/heavy syntax for clarity.<br>
<br>
-Chris<br>
<div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
</div></div></blockquote></div><br></div></div>