lox_one 0.1.0

A tree-walking interpreter for the Lox programming language.
Documentation
use crate::interpreter::Interpreter;
use crate::lox_value::LoxValue;

use crate::interpreter::error::RuntimeResult;

/// This trait is shared among all types that can be called
/// like functions and class instantiations.
pub trait Callable {
    /// Returns the name of the callable.
    fn name(&self) -> String;
    /// Returns the number of arguments taken by the callable.
    fn arity(&self) -> usize;
    /// Takes a `&mut Interpreter` and calls the function on it.
    fn call(&self, interpreter: &mut Interpreter, args: &[LoxValue]) -> RuntimeResult<LoxValue>;
}