Is magic method indexing Tuples an anti-pattern?

...in addition to variardic generics ? e.g.

  • variardics would process each element of a tuple using a plymorphic fn + a special map! built-in
  • indexing would provide access to a single tuple member by number?

.

I guess after harmonization with the proposed "variardic" syntax the `get` function would be spelled:
// ... is a splice operator that turns a tuple type into a list of types
// (...T) is tuple type T spliced and wrapped back into a tuple, e.g. equals T
// yet using (...T) in a generic parameter position communicates the constraint that T is a tuple type
const fn get<(...T), const I: uszie>(t : T) -> T[I] { t[I] }
// or equivalently
const fn get<T, const I: uszie>(t : (...T)) -> T[I] { t[I] }
// or equivalently
const fn get<(...T), const I: uszie>(t : (...T)) -> T[I] { t[I] }
// the point is that we do use `(...T)` somewhere in the signature
// to communicate T is a tuple type
1 Like