The tuple types are a family of generic types. Like the simple types, they are identified by the
keyword "Tuple". A tuple is an ordered list of values that can be of different types.
Tuples are const value types. This does mean that a tuple cannot contain an iso or owned type.
In fact, all generic arguments must be aliasable. Tuples are conditional drop types and can
contain drop types.
tuple_type
: "Tuple" "[" type{",", 0, *} "]"
;
TODO: allow large tuples to be partially reference types
The number of values in a tuple can be accessed using the "count" field which is of type "size".
Tuples can be constructed using the tuple initializer syntax.
let t = #(1, "something"); // t: Tuple[int, string]
The individual fields of a tuple can be accessed using a destructuring pattern.
let x, y, z = #(1, 2, 3);
console.WriteLine("x = \(x)");
Tuple fields can also be accessed by a zero based index. This is consistent with collections which are zero based. Tuple values can be directly accessed as properties by escaping the index name.
let t = #(1, 2, 3);
let x = t.\0;
let y = t.\1;
let z = t.\2;