> 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
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
You would have this guarantee with the fixed-size arrays currently being
discussed.
Perhaps this could be an amendment to that proposal - you could declare an
array with bounds for its size.
Fixed-size arrays would be a subset of those where the upper and lower bounds
are equal.
They could
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.