class Op
Persistent expression Operator.
index
members
-
op:all_inputs()
– yield all Inputs from the (potentially nested) inputs table -
op:fork()
– create a mutable copy of this Op. -
op.state
– internal state of this Op. -
op.out
– Result instance representing this Op’s computed output value. -
op.inputs
– table containing Inputs to this Op.
op interface
-
Op(out, state)
– construct a new instance. -
op:setup(inputs, scope)
– parse arguments and patch self. -
op:tick(setup)
– handle incoming events and update out (optional). -
op:destroy()
– called when the Op is destroyed (optional). -
op:vis()
– collect visualisation data (optional). -
op:poll()
– poll for external changes (optional).
implementation utilities
-
op:setup(inputs)
– setup previous inputs, if any, with the new inputs, and write them to inputs. -
op:setup_out(metatype, type[, val])
– create or update out. -
op:unwrap_all()
–\unwrap
all Inputs in@inputs
and return a table with the same shape.
details
members
-
– yield all Inputs from the (potentially nested) inputs table
returns:
- (iterator): iterator over inputs
- – create a mutable copy of this Op.
-
– internal state of this Op.
This may be any simple Lua value, including Lua tables, as long as it has no metatables, multiple references/loops, userdata etc.
-
– Result instance representing this Op’s computed output value.
Must be set to a Result instance once setup finishes. Must not change type, be removed or replaced outside of new and setup. If it is a
ValueStream
, it should have a value assigned viaset
or the constructor once tick is called the first time. If out’s value is not initialized in new or setup, the implementation must make sure tick(true)
is called at least on the first eval-cycle the Op goes through, e.g. by using an Input.hot with aValueStream
. - – table containing Inputs to this Op.
op interface
- – construct a new instance.
-
– parse arguments and patch self.
Called once every eval-cycle. inputs is a list of RTNodes that are the argument to this op. The inputs have to be wrapped in Input instances to define update behaviour. Use base.match to parse them, then delegate to
super:setup
to patch the Input instances.parameters:
- a sequence of RTNodes
- the active scope
-
– handle incoming events and update out (optional).
Called once per frame if any Inputs are dirty. Some Inputs may have special behaviour immediately after setup that can cause them to become dirty at eval-time. In this case, an eval-time tick is executed. You can detect this using the setup parameter.
tick is called after setup. tick is not called immediately after setup if no inputs are dirty. Update out here.
parameters:
- whether this is an eval-time tick
-
– called when the Op is destroyed (optional).
-
– 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
-
– poll for external changes (optional).
If implemented, this method will be called at a high frequency and should return
true
whenever processing is required due to an external event or condition. After polling all such IO Ops a new tick will be executed if any returned true. The implementation of poll is responsible for triggering the tick method by writing to an internally allocated Result that has been inserted into inputs.returns:
- (optional boolean): dirty whether processing is required
implementation utilities
- – setup previous inputs, if any, with the new inputs, and write them to inputs.
-
– create or update out.
This should be used instead of setting out directly. It will try to keep the current value if possible.
parameters:
-
(one of
!
or~
) - initial value (optional)
-
(one of
-
–
\unwrap
all Inputs in@inputs
and return a table with the same shape.