fn compile_function(function_def: &FunctionBinding) -> Result<CompiledActions, BindError> {
    // Create the cell that contains the function
    let fun = match (function_def.reference_type, &*function_def.definition) {
        (ReferenceType::ReturnsMonad, FunctionDefinition::Lambda(fun))  => SafasCell::FrameMonad(Box::new(ReturnsMonad(fun.clone()))),
        (ReferenceType::ReturnsMonad, FunctionDefinition::Closure(fun)) => SafasCell::FrameMonad(Box::new(ReturnsMonad(fun.clone()))),
        (_, FunctionDefinition::Lambda(fun))                            => SafasCell::FrameMonad(Box::new(fun.clone())),
        (_, FunctionDefinition::Closure(fun))                           => SafasCell::FrameMonad(Box::new(fun.clone()))
    };

    // Closures need to be called to bind their values before the function can be called
    match &*function_def.definition {
        FunctionDefinition::Lambda(_)       => Ok(smallvec![Action::Value(fun.into())].into()),
        FunctionDefinition::Closure(_)      => Ok(smallvec![Action::Value(fun.into()), Action::Call].into())
    }
}
///
/// Compiles a function definition to the corresponding actions
///
Compiles a function definition to the corresponding actions
Compiles a function definition to the corresponding actions
fn compile_function(function_def: &FunctionBinding) -> Result<CompiledActions, BindError> {
    // Create the cell that contains the function
    let fun = match (function_def.reference_type, &*function_def.definition) {
        (ReferenceType::ReturnsMonad, FunctionDefinition::Lambda(fun))  => SafasCell::FrameMonad(Box::new(ReturnsMonad(fun.clone()))),
        (ReferenceType::ReturnsMonad, FunctionDefinition::Closure(fun)) => SafasCell::FrameMonad(Box::new(ReturnsMonad(fun.clone()))),
        (_, FunctionDefinition::Lambda(fun))                            => SafasCell::FrameMonad(Box::new(fun.clone())),
        (_, FunctionDefinition::Closure(fun))                           => SafasCell::FrameMonad(Box::new(fun.clone()))
    };
    // Closures need to be called to bind their values before the function can be called
    match &*function_def.definition {
        FunctionDefinition::Lambda(_)       => Ok(smallvec![Action::Value(fun.into())].into()),
        FunctionDefinition::Closure(_)      => Ok(smallvec![Action::Value(fun.into()), Action::Call].into())
    }
}
fn compile_function ( function_def : & FunctionBinding ) -> Result < CompiledActions , BindError > { // Create the cell that contains the function let fun = match ( function_def . reference_type , & * function_def . definition ) { ( ReferenceType :: ReturnsMonad , FunctionDefinition :: Lambda ( fun ) ) => SafasCell :: FrameMonad ( Box :: new ( ReturnsMonad ( fun . clone ( ) ) ) ) , ( ReferenceType :: ReturnsMonad , FunctionDefinition :: Closure ( fun ) ) => SafasCell :: FrameMonad ( Box :: new ( ReturnsMonad ( fun . clone ( ) ) ) ) , ( _ , FunctionDefinition :: Lambda ( fun ) ) => SafasCell :: FrameMonad ( Box :: new ( fun . clone ( ) ) ) , ( _ , FunctionDefinition :: Closure ( fun ) ) => SafasCell :: FrameMonad ( Box :: new ( fun . clone ( ) ) ) } ; // Closures need to be called to bind their values before the function can be called match & * function_def . definition { FunctionDefinition :: Lambda ( _ ) => Ok ( smallvec ! [ Action Value ( fun into ( ) ) ] . into ( ) ) , FunctionDefinition :: Closure ( _ ) => Ok ( smallvec ! [ Action Value ( fun into ( ) ) Action Call ] . into ( ) ) } }
Compiles a function definition to the corresponding actions
Compiles a function definition to the corresponding actions
function_def
&FunctionBinding
function_def
&FunctionBinding