I am creating a dynamic toy language (I am afraid of javascript), and although my implementation is on top of DLR, I decided that solving this problem would be a rather agnostic language / platform.
I have no problem compiling recursive functions or mutually recursive functions that exist side by side. But compiling nested mutually recursive functions turned out to be much more complicated.
The sample function I use for testing is as follows
void f(int x) {
void g(int y) {
if((x + y) < 100) {
f(x + y);
} else {
print(x + y);
}
}
g(x);
}
I realized that the solution to this issue should be fairly general (maybe I'm wrong) and not specific to DLR, I believe that I somehow need to discard the internal definition of g and define it to f and still keep the closure context.