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

Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.

src/components/destructuring.x

Flat List destructuring.

Design notes

A destructuring reads its source once as a List and gives each target the element at its position, left to right; the compiler converts each element as an ordinary assignment or initialization does. The parser has declared the targets, so each rule answers bound code that keeps their bindings: T (a, b) = source; declares a and b before the read, (T1 a, T2 b) = source; declares each initialized from its element, an assignment statement reads in its own block, and an assignment expression keeps its source in a result local as its value. The List local and the result local are fresh names the carrier asks for.