Tuple Expression
A tuple expression constructs a tuple value from element expressions.
A tuple expression contains at least two element expressions. An expression enclosed in parentheses without element separators is a parenthesized expression, which has the same value and type as its enclosed expression; the two forms are unambiguous, since a comma separates tuple elements only at the outermost level of the enclosing parentheses.
Process
At runtime:
- the element expressions are evaluated, left to right; and
- a tuple value of their values, in order, is constructed.
Assertions
- Each element has a type, and the tuple's type is the tuple type whose element types are those types.
- When an expected tuple type exists, each element's expected type is the corresponding element of the expected tuple type.
- A tuple expression whose element values are all of the type type has the
typetype itself: its value is the tuple type of those element types.
Syntax
tuple_expression = left_paren, expression, comma, expression, { comma, expression }, right_paren ;