recursive nested functions

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

          From comp.compilers

Related articles
recursive nested functions nojb@uchicago.edu (nojb) (2010-06-25)
Re: recursive nested functions cfc@shell01.TheWorld.com (Chris F Clark) (2010-06-27)
Re: recursive nested functions gene.ressler@gmail.com (Gene) (2010-06-27)
Re: recursive nested functions cr88192@hotmail.com (BGB / cr88192) (2010-06-28)
| List of all articles for this month |

From: nojb <nojb@uchicago.edu>
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

Hello,


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,
N
[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.