Closed alanrgan closed 7 years ago
With regard to scope, we have to consider the following cases:
fn foo() : Fn<_,_> {
let x: Fn<_,_> = fn { print("hi"); };
return x;
}
The function fn { print("hi"); };
is not defined in the caller scope and only a FnPtr is returned.
fn foo() : Fn<_,_> {
return fn { print("hi");};
}
fn bar() : Fn<_,_> {
return foo();
}
Pass definition upstream
Functions should be able to be returned from other functions:
Considerations
What scope will the returned function be defined in, and how will chained function calls be handled? In the above example, foo() needs to be evaluated before '3' is passed into the returned function.
Proposed solution is to push parameters onto a queue and then consume the queue at its head two at a time: