Trait endbasic_core::syms::Function[][src]

pub trait Function {
    fn metadata(&self) -> &CallableMetadata;
fn exec<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        args: &'life1 [Expr],
        symbols: &'life2 mut Symbols
    ) -> Pin<Box<dyn Future<Output = FunctionResult> + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
; }
Expand description

A trait to define a function that is executed by a Machine.

The functions themselves are, for now, pure. They can only access their input arguments and cannot modify the state of the machine.

Idiomatically, these objects need to provide a new() method that returns an Rc<Callable>, as that’s the type used throughout the execution engine.

Required methods

Returns the metadata for this function.

The return value takes the form of a reference to force the callable to store the metadata as a struct field so that calls to this function are guaranteed to be cheap.

Executes the function.

args contains the unevaluated arguments as provided in the invocation of the function. These are needed to support functions that need unevaluated symbol references (such as LBOUND(array)). Because most functions don’t support this kind of input, they should use eval::eval_all to process all arguments.

symbols provides mutable access to the current state of the machine’s symbols.

Implementors