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

Scope Expression

A scope expression is a brace-enclosed sequence of let bindings followed by a final expression; the final expression's value is the scope's value.

Process

At runtime:

  1. the let bindings are evaluated in order, each binding its name to its expression's value; and
  2. the final expression is evaluated, and its value is the scope's value.

Bindings

Each binding has the type of its expression, and is visible from its point of definition through the end of the enclosing scope, shadowing bindings of enclosing scopes as well as namespace and global declarations; see the reference resolution order. A binding may hold a value of any type, including a type or namespace value, which may then be used in type positions or as the operand of static access.

In expression position a leading left_brace is unambiguous: a construction requires a preceding operand.

Assertions

  1. No name is bound twice within a single scope.
  2. Every binding's expression, the final expression, and every reference to a binding resolve.

No sub-expression of a scope expression has an expected type.

Syntax

let_binding = let, identifier, equal, expression, semicolon ;

scope_expression = left_brace, { let_binding }, expression, right_brace ;