Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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:

  1. the element expressions are evaluated, left to right; and
  2. a tuple value of their values, in order, is constructed.

Assertions

  1. Each element has a type, and the tuple's type is the tuple type whose element types are those types.
  2. When an expected tuple type exists, each element's expected type is the corresponding element of the expected tuple type.
  3. A tuple expression whose element values are all of the type type has the type type itself: its value is the tuple type of those element types.

Syntax

tuple_expression = left_paren, expression, comma, expression, { comma, expression }, right_paren ;