[swift-evolution] Strings in Swift 4

Matt Whiteside mwhiteside.dev at gmail.com
Thu Jan 26 22:01:33 CST 2017


Thanks for pointing this out to me.

-Matt

> On Jan 25, 2017, at 13:10, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
> 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
>> distinguish?
> 
> The variadic use cases don't always have ... appearing inside angle
> brackets.  See “pack expansion” at
> http://en.cppreference.com/w/cpp/language/parameter_pack
> for example.
> 
> -- 
> -Dave
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list