|recursive nested functions email@example.com (nojb) (2010-06-25)|
|Re: recursive nested functions cfc@shell01.TheWorld.com (Chris F Clark) (2010-06-27)|
|Re: recursive nested functions firstname.lastname@example.org (Gene) (2010-06-27)|
|Re: recursive nested functions email@example.com (BGB / cr88192) (2010-06-28)|
|Date:||Fri, 25 Jun 2010 10:30:03 -0700 (PDT)|
|Posted-Date:||25 Jun 2010 16:27:21 EDT|
I'm writing a compiler for a language that admits recursive nested
functions and I am stuck trying to figure out how to handle them. My
objective is to lift all nested functions to top level and pass all
their free variables explicitly as parameters. For this, I have to
figure out which variables are free. So when I'm analyzing the body
of each function, I record its free variables. But then obviously when
I come across a function call, I have to add _its_ free variables to
the list of the enclosing function. You can see how this will loop
endlesly if we allow recursive functions...
I would guess there is a standard way to handle this, so if anyone can
point me to it, it would be greatly appreciated.
Thank you very much,
[I think you'll find that the usual approach is to expand out to N levels
for a relatively small N, then give up and generate normal calls. -John]
Return to the
Search the comp.compilers archives again.