Vector, a fixed-size array

I appreciate the effort and understand the need for a fixed-size collection type, but I have some reservations regarding the proposed approach.

The Motivation section begins by addressing the use of tuples, which is a valid and efficient solution available in Swift today. Tuples are particularly well-suited for this use case due to their static, inlined nature, resulting in a low memory footprint. However, the argument highlights the lack of collection-style APIs for tuples.

It’s worth noting that there have been previous efforts, such as Slava’s pitch on User-defined tuple conformances, aimed at addressing this limitation. Have you considered this as an alternative? While that proposal primarily covers Equatable and Hashable conformances, extending it to make tuples conform to ExpressibleByArrayLiteral, Collection, or MutableCollection could be equally effective in providing the desired functionality.

It’s perfectly valid to prefer a nominal type over a structural tuple for this use case, but I’d like to better understand the trade-offs involved, especially in comparison to a simpler alternative that avoids the complexity of introducing integer generics.

1 Like