on Fri Apr 14 2017, Karl Wagner <[email protected]> wrote: > Personally, the only valid use-case I can think of is when you want to > initialise an Array’s elements out-of-order - i.e., you want to set a > value for myArray[2] despite myArray[0] and [1] not being > populated. In that case, it would be better to have some kind of > SparseArray type, and for us to have a proper API for unsafe > initialisation of stdlib types.
That is a point in the design space, but there's really no need to expose unsafe initialization in order to get that functionality. You could simply build ArrayOfOptional<T> that would present the same API as Array<T?> but would use a separate inline buffer of bits to denote which of the optionals were non-nil. -- -Dave _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
