Nested functions will provide the required scope definition. Note that there is no other way to call the f2 callback function than either from within f1 or through the function descriptor. That way, f1 can return the @f2
handle, and other functions in the global scope can call it that way.
function f1() setup_callback(@f2); a = 1; evaluate_callback(); function f2() % refer to a ... end end
Peter source share