fn subtitute_function_references(function_def: &FunctionBinding, substitute: &mut dyn FnMut(FrameReference) -> Option<CellRef>) -> SyntaxCompiler {
    // Rebind the function. Lambdas require no rebinding, but closures might require new bindings from the substitution function
    let new_binding = match &*function_def.definition {
        FunctionDefinition::Lambda(lambda)      => FunctionDefinition::Lambda(lambda.clone()),
        FunctionDefinition::Closure(closure)    => FunctionDefinition::Closure(closure.substitute_frame_references(substitute))
    };

    // Create two copies of the definition for the compiler and the substitution routine
    let function_def        = FunctionBinding {
        reference_type: function_def.reference_type,
        definition:     Arc::new(new_binding)
    };
    let substitute_function = function_def.clone();
    let reference_type      = function_def.reference_type;

    // Create the new syntax for this function
    SyntaxCompiler::custom(
        move || { compile_function(&function_def) },
        move |map_cell| { subtitute_function_references(&substitute_function, map_cell) },
        reference_type
    )
}
///
/// Substitutes the values in a function reference
///
Substitutes the values in a function reference
Substitutes the values in a function reference
fn subtitute_function_references(function_def: &FunctionBinding, substitute: &mut dyn FnMut(FrameReference) -> Option<CellRef>) -> SyntaxCompiler {
    // Rebind the function. Lambdas require no rebinding, but closures might require new bindings from the substitution function
    let new_binding = match &*function_def.definition {
        FunctionDefinition::Lambda(lambda)      => FunctionDefinition::Lambda(lambda.clone()),
        FunctionDefinition::Closure(closure)    => FunctionDefinition::Closure(closure.substitute_frame_references(substitute))
    };
    // Create two copies of the definition for the compiler and the substitution routine
    let function_def        = FunctionBinding {
        reference_type: function_def.reference_type,
        definition:     Arc::new(new_binding)
    };
    let substitute_function = function_def.clone();
    let reference_type      = function_def.reference_type;
    // Create the new syntax for this function
    SyntaxCompiler::custom(
        move || { compile_function(&function_def) },
        move |map_cell| { subtitute_function_references(&substitute_function, map_cell) },
        reference_type
    )
}
fn subtitute_function_references ( function_def : & FunctionBinding , substitute : & mut dyn FnMut ( FrameReference ) -> Option < CellRef > ) -> SyntaxCompiler { // Rebind the function. Lambdas require no rebinding, but closures might require new bindings from the substitution function let new_binding = match & * function_def . definition { FunctionDefinition :: Lambda ( lambda ) => FunctionDefinition :: Lambda ( lambda . clone ( ) ) , FunctionDefinition :: Closure ( closure ) => FunctionDefinition :: Closure ( closure . substitute_frame_references ( substitute ) ) } ; // Create two copies of the definition for the compiler and the substitution routine let function_def = FunctionBinding { reference_type : function_def . reference_type , definition : Arc :: new ( new_binding ) } ; let substitute_function = function_def . clone ( ) ; let reference_type = function_def . reference_type ; // Create the new syntax for this function SyntaxCompiler :: custom ( move | | { compile_function ( & function_def ) } , move | map_cell | { subtitute_function_references ( & substitute_function , map_cell ) } , reference_type ) }
Substitutes the values in a function reference
Substitutes the values in a function reference
function_def
&FunctionBinding
substitute
&mut dyn FnMut(FrameReference) -> Option<CellRef>
function_def
&FunctionBinding
substitute
&mut dyn FnMut(FrameReference) -> Option<CellRef>