recursive nested functions

nojb <>
Fri, 25 Jun 2010 10:30:03 -0700 (PDT)

          From comp.compilers

Related articles
recursive nested functions (nojb) (2010-06-25)
Re: recursive nested functions (Chris F Clark) (2010-06-27)
Re: recursive nested functions (Gene) (2010-06-27)
Re: recursive nested functions (BGB / cr88192) (2010-06-28)
| List of all articles for this month |

From: nojb <>
Newsgroups: comp.compilers
Date: Fri, 25 Jun 2010 10:30:03 -0700 (PDT)
Organization: Compilers Central
Keywords: optimize, question
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]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.