[swift-evolution] Strings in Swift 4
dabrahams at apple.com
Wed Jan 25 15:10:42 CST 2017
on Tue Jan 24 2017, Matt Whiteside <swift-evolution at swift.org> wrote:
>> On Jan 22, 2017, at 15:40, Chris Lattner via swift-evolution
> <swift-evolution at swift.org> wrote:
>> 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]”:
>> 1) Provide "c[i...]":
>> 2) Provide "c[i..<]":
>> 3) Provide both "c[i..<]” and "c[i…]":
>> Since all of these operations would have the same behavior, it comes down to subjective questions:
>> a) Do we want redundancy? IMO, no, which is why #3 is not very desirable.
>> 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.
>> 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 ].
>> There is no obvious winner, but to me, I tend to prefer #1. What do other folks think?
> I also prefer #1. It’s a shame that this conflicts with the potential
> syntax for variadic generics. Is there really no way around this?
> I’m showing my ignorance on compilers here, but couldn’t the fact that
> variadic generics will be inside angle brackets be used to
The variadic use cases don't always have ... appearing inside angle
brackets. See “pack expansion” at
More information about the swift-evolution