class Builtin
Builtin / Special Form evaluation Strategy (builtin).
Responsible for quoting/evaluating subexpressions, instantiating and setting up Ops, updating the current Scope, etc. See builtin and invoke for examples.
index
builtin interface
-
builtin\new(cell, head)
– create a new instance. -
builtin\eval(scope, tail)
– perform the actual evaluation. -
builtin\eval(node)
– store the evaluation result for access by editor and return it. -
builtin\destroy()
– free resources -
builtin\setup(prev)
– setup or copy state from previous instance of same type. -
builtin\vis()
– collect visualisation data (optional). -
builtin.cell
– the Cell this Builtin was created for. -
builtin.head
– the evaluated head of cell. -
builtin.tag
– the identity of cell. -
builtin.node
– the last result of eval.
static functions
-
Builtin\eval_cell(cell, scope, head)
– create and setup a Builtin for a given tag, then evaluate it.
details
builtin interface
-
– create a new instance.
parameters:
- the Cell to evaluate
- the (AST:evald) head of the Cell to evaluate
-
– perform the actual evaluation.
Implementations should:
- eval or quote tail values
- perform scope effects
- wrap all child-results
parameters:
- the active scope
- the arguments to this expression
returns:
- (RTNode): the result of this evaluation
-
– store the evaluation result for access by editor and return it.
This should always be called via super as the last statement in all overriden eval methods.
parameters:
- the evaluation result
-
– free resources
-
– setup or copy state from previous instance of same type.
prev is only passed if Builtin types of prev and current expression match. Otherwise, or when no previous expression exists, nil is passed.
parameters:
- the previous Builtin instance
-
– collect visualisation data (optional).
This may return any simple Lua value, including Lua tables, as long as it has no metatables, multiple references/loops, userdata etc.
This value is exposed to alv editors in order to render realtime visualisations overlaid onto the program text.
returns:
- (table): vis
-
– the Cell this Builtin was created for.
-
– the evaluated head of cell.
-
– the identity of cell.
-
– the last result of eval.
static functions
-
– create and setup a Builtin for a given tag, then evaluate it.
Create a new instance using tag and head and call setup on it. If a previous instance with the same tag exists and has the same head, it pass it to setup. Register the Builtin with tag, evaluate it and return the RTNode.
parameters:
- the Cell being evaluated
- the active scope
- the (AST:evald) head of the Cell being evaluated
returns:
- (RTNode): the result of evaluation