Trait Apply

Source
pub trait Apply<C: Ctx, E: UserEvent>:
    Debug
    + Send
    + Sync
    + 'static {
    // Required method
    fn update(
        &mut self,
        ctx: &mut ExecCtx<C, E>,
        from: &mut [Node<C, E>],
        event: &mut Event<E>,
    ) -> Option<Value>;

    // Provided methods
    fn delete(&mut self, _ctx: &mut ExecCtx<C, E>) { ... }
    fn typecheck(
        &mut self,
        _ctx: &mut ExecCtx<C, E>,
        _from: &mut [Node<C, E>],
    ) -> Result<()> { ... }
    fn typ(&self) -> Arc<FnType> { ... }
    fn refs<'a>(&'a self, _f: &'a mut (dyn FnMut(BindId) + 'a)) { ... }
}
Expand description

Apply is a kind of node that represents a function application. It does not hold ownership of it’s arguments, instead those are held by a CallSite node. This allows us to change the function called at runtime without recompiling the arguments.

Required Methods§

Source

fn update( &mut self, ctx: &mut ExecCtx<C, E>, from: &mut [Node<C, E>], event: &mut Event<E>, ) -> Option<Value>

Provided Methods§

Source

fn delete(&mut self, _ctx: &mut ExecCtx<C, E>)

delete any internally generated nodes, only needed for builtins that dynamically generate code at runtime

Source

fn typecheck( &mut self, _ctx: &mut ExecCtx<C, E>, _from: &mut [Node<C, E>], ) -> Result<()>

apply custom typechecking to the lambda, only needed for builtins that take lambdas as arguments

Source

fn typ(&self) -> Arc<FnType>

return the lambdas type, builtins do not need to implement this, it is implemented by the BuiltIn wrapper

Source

fn refs<'a>(&'a self, _f: &'a mut (dyn FnMut(BindId) + 'a))

push a list of variables the lambda references in addition to it’s arguments. Builtins only need to implement this if they lookup and reference variables from the environment that were not explicitly passed in.

Implementors§

Source§

impl<C: Ctx, E: UserEvent, T: MapFn<C, E>> Apply<C, E> for MapQ<C, E, T>

Source§

impl<C: Ctx, E: UserEvent, T: EvalCached> Apply<C, E> for CachedArgs<T>