[swift-evolution] Proposal: Contiguous Variables (A.K.A. Fixed Sized Array Type)

Daniel Vollmer lists at maven.de
Wed Feb 3 05:43:14 CST 2016


> On 3 Feb 2016, at 05:10, Justin Kolb via swift-evolution <swift-evolution at swift.org> wrote:
> It seems that while similar to tuples, fixed sized arrays are definitely not a tuple.

I sort of disagree, but in my mind (and coming from a C++ background) (compile-time) fixed-size arrays could be regarded as a specific subset of tuples, namely the ones where all elements have the same type.
If we had the capability to have the subscript-operator / indexing return different types depending on the argument (which then would have to be known at compile-time), this would fall in place pretty nicely.

That said, the ability to index the type with value only known at run-time (and something like a .data() contiguous buffer view) would be a refinement only available on the fixed-size array variant.

Either way, I’m not sure whether it’s better to model this as separate types (e.g. std::tuple vs std::array) or not, but I am convinced that the way tuple is used now for mapping fixed-size arrays from C-headers should be improved, especially with some functionality of tuples (e.g. comparison, ordering IIRC?) being restricted to low arities.


More information about the swift-evolution mailing list