[Second review] SE-0453: Vector, a fixed size array

I like the name InlineArray because I think it's important to make clear the storage is inline more than anything else about this type.

To me, the word "array" doesn't mean the container size is variable at runtime. An array is just a list of elements placed adjacent in memory. That Swift.Array can grow or shrink doesn't imply all arrays can grow or shrink.

I see Vector as an invitation for every library to add their own operations to the type when they should really just create their own domain-specific wrapper. This type shouldn't be named in a way that implies it can do more than just store values.


As an aside, I'm still wondering if we could still use tuple-like syntax.

Perhaps like this:

let u: (3 Int) = (2, 3, 5)

This would make a tuple of 3 Ints, but it'd be a distinct type from the normal tuple (Int, Int, Int) in order to get the correct padding at the end. We could call this kind of type a homogeneous tuple, or maybe an array tuple. And we probably could enable implicit conversions between the two in many situations.

Like a normal tuple, a homogenous/array tuple wouldn't be a named type so you can't write extensions for it. Also like a normal tuple, built-in conformances to certain standard library protocols could be part of the type. And like a tuple, the storage is inline and fixed in size and the values are always initialized, so those expectations are already baked in.

But there's still plenty of fuzzy details I haven't though about so maybe it's not a good idea.

3 Likes