Starting to implement Variadic Generics

There are two key properties of tuples that I think are important going forward for a variadics design, which I think would be difficult to maintain if they were made into nominal types. First of all, as @technicated noted, there needs to be some primitive type associated with packing and unpacking variadics at the value level. If tuples are themselves a struct, but are also the primitive interface to variadic value, there becomes a circularity issue in defining tuples; alternatively, we'd need to invent different primitives that allow Tuple to be constructed, and I'd be concerned that that design space leads to a much more complex design. Allowing tuples to remain primitive, I believe, allows variadics in turn to be simpler, so I think the complexity cost we pay for special-casing tuples pays off in reducing the net complexity of the language.

Secondly, I think it's very important for the ergonomics of variadics that we keep (T) == T in the type system, and I can only think of very awkward ways we could express that in terms of nominal types. There should not need to be a need to distinguish them in the type system if tuples are integrated with variadics, because we know from type context whether a type variable is variadic or not, and therefore whether a value is concretely a single scalar value or a scalar value bound as the single argument to a variadic parameter.

7 Likes