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/lambdas.x

Lambda parsing and capture resolution.

Functions

FunctionSummary
Compiler.begin_lambda_capturesOpens lexical capture resolution while a lambda body is parsed or bound.
Compiler.bind_lambda_expressionBinds a constructed lambda through the lexical capture operations used by source literals.
Compiler.capture_lambda_identifierResolves an automatic identifier through each enclosing lambda’s captures.
Compiler.check_lambda_capturesRejects writes and reference access to read-only snapshot bindings.
Compiler.end_lambda_capturesFinishes the active lambda’s captures in first-use order.
Compiler.lambda_capture_requiredReports whether the active lambda still needs to capture a binding.
Compiler.lambda_param_typesThe parameter types of a lambda’s function signature, keeping typed declarators; a bare parameter is a Var.
Compiler.parse_lambda_literalParses a %!(...) => ... literal and returns its typed lambda expression.

Compiler

Compiler.begin_lambda_captures

void Compiler.begin_lambda_captures( Compiler c, List references, List supplied)

Opens lexical capture resolution while a lambda body is parsed or bound. references names explicitly shared surrounding bindings; supplied contains canonical capture rows supplied by constructed syntax. Evolving rows live in semantic binding facts so macro transactions restore them.

Source: src/lambdas.x:358

Compiler.bind_lambda_expression

List Compiler.bind_lambda_expression( Compiler c, Type type, List parameters, List supplied, List body)

Binds a constructed lambda through the lexical capture operations used by source literals. Parameter declarations keep their existing declarators; supplied canonical capture rows retain their value or reference mode.

Source: src/lambdas.x:236

Compiler.capture_lambda_identifier

List Compiler.capture_lambda_identifier(Compiler c, List binding, Type type)

Resolves an automatic identifier through each enclosing lambda’s captures. Fresh captured bindings keep sibling snapshots independent of shared-cell rewriting. Reference captures preserve qualifiers; snapshots of reference parameters copy their current referents.

Source: src/lambdas.x:389

Compiler.check_lambda_captures

void Compiler.check_lambda_captures(Compiler c, List ast)

Rejects writes and reference access to read-only snapshot bindings. The body has already resolved identifiers and call arguments. Templates defer this check until expansion; nested lambdas check their own bodies.

Source: src/lambdas.x:517

Compiler.end_lambda_captures

List Compiler.end_lambda_captures(Compiler c)

Finishes the active lambda’s captures in first-use order.

Source: src/lambdas.x:367

Compiler.lambda_capture_required

int Compiler.lambda_capture_required(Compiler c, List binding)

Reports whether the active lambda still needs to capture a binding.

Source: src/lambdas.x:376

Compiler.lambda_param_types

List Compiler.lambda_param_types(Compiler c, List entries)

The parameter types of a lambda’s function signature, keeping typed declarators; a bare parameter is a Var.

Source: src/lambdas.x:195

Compiler.parse_lambda_literal

List Compiler.parse_lambda_literal(Compiler c)

Parses a %!(...) => ... literal and returns its typed lambda expression. Parameter bindings are in a new Sym scope, bodies use Var as the active return type, and capture rows come from semantic_binding_facts. Capturing lambdas have type Func; noncapturing lambdas retain a native function type.

Source: src/lambdas.x:60

Design notes

A source lambda and a lambda that a macro or transform constructs bind through the same capture operations, which record each captured binding and its value or reference mode in semantic binding facts. The rows leave here resolved and in first-use order; callables.x lowers them.