Re: [swift-evolution] [Pitch?] Way to declare a Swift Array that guarantees it can't be empty

2017-08-08 Thread Tino Heth via swift-evolution

> Fixed-size arrays do not solve this particular issue that I've noted above.
And I didn't say so ;-)
But generic value parameters would not only allow you to define fixed-size 
arrays, but also arrays with certain other properties:
Minimal size, maximal size… maybe even number of elements or other more 
complicated things.
(that is one reason why I think this is the best approach — its more versatile 
than the alternative)

I really hope that you find supporters for non-empty arrays - that would also 
be a strong motivation to add subtyping for arrays ;-) (struct NonEmptyArray: 
Array)___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] [Pitch?] Way to declare a Swift Array that guarantees it can't be empty

2017-08-08 Thread Charlie Monroe via swift-evolution
I had a similar though some time ago (and even suggested it here) - as e.g. 
"Hello".components(separatedBy: "123") will always produce a non-empty array. 
Even "".components(separatedBy: "") is [""].

Which would allow e.g. first, last and some other members to loose the 
optionality - which would be great. But would probably add unnecessary 
complexity to the stdlib.

Fixed-size arrays do not solve this particular issue that I've noted above.

> On Aug 8, 2017, at 1:39 PM, Tino Heth via swift-evolution 
>  wrote:
> 
> I think it would make sense to have arrays with a minimal size, but wouldn't 
> consider it very important.
> But there is a long-running discussion about fixed-size arrays, and depending 
> on (if any) solution is chosen for them, your use case could be solved rather 
> easy as well.
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] [Pitch?] Way to declare a Swift Array that guarantees it can't be empty

2017-08-08 Thread Tino Heth via swift-evolution
I think it would make sense to have arrays with a minimal size, but wouldn't 
consider it very important.
But there is a long-running discussion about fixed-size arrays, and depending 
on (if any) solution is chosen for them, your use case could be solved rather 
easy as well.
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution