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(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.
-
– 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
- eval or quote
-
– 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.