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

Alloc Expression

An alloc expression allocates storage for a value and yields a handle to it.

An alloc expression has the handle type &T, where T is the initializer expression's type.

Process

At runtime:

  1. enough space for a value of the initializer expression's type is allocated, see region allocation;
  2. the initializer expression is evaluated;
  3. its result is stored in the allocated space; and
  4. a handle to the newly allocated storage is returned.

Assertions

  1. The initializer expression's type is runtime representable.

Syntax

alloc_handle_expression = alloc, unary_expression ;