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

pub trait Function {
    fn metadata(&self) -> &CallableMetadata;
fn exec(&self, args: Vec<Value>, symbols: &mut Symbols) -> FunctionResult; }

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

fn metadata(&self) -> &CallableMetadata[src]

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.

fn exec(&self, args: Vec<Value>, symbols: &mut Symbols) -> FunctionResult[src]

Executes the function.

args contains the evaluated arguments as provided in the invocation of the function. symbols provides mutable access to the current state of the machine's symbols.

Loading content...

Implementors

Loading content...