LEVIATHAN v962456e · 962456eee1

Standard Library · expr

class Bind

A captured value, referred to by its position in the binds array of the enclosing expr::Expr.

since 0.1.0-alpha.1linuxwindowswasm

bases
Node

Overview

Any chain of names in the lambda that does not start at a lambda parameter becomes one Bind. Its value is read once, when the Expr is built, and stored in binds.

Examples

Array<string | int | float | bool | None> binds = [18, "ada"];
expr::Bind b = expr::Bind(1);
match (binds[b.slot]) {
    string => { console.writeln("slot ${b.slot} holds a string"); }
    else   => { console.writeln("slot ${b.slot} holds something else"); }
}
slot 1 holds a string

Constructors

new

new(int s)

Create a bind node.

Parameters

s
The index into the binds array.

Examples

expr::Bind b = expr::Bind(2);
console.writeln(b.slot);
2

Fields

slot

int slot

The index into the binds array that holds the captured value.

See also

  • Expr — A lambda together with a walkable description of its body.