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) |
From: | "BGB / cr88192" <cr88192@hotmail.com> |
Newsgroups: | comp.compilers |
Date: | Mon, 28 Jun 2010 17:17:24 -0700 |
Organization: | albasani.net |
References: | 10-06-078 10-06-087 |
Keywords: | analysis, optimize |
Posted-Date: | 29 Jun 2010 11:11:15 EDT |
"Gene" <gene.ressler@gmail.com> wrote in message
> On Jun 25, 1:30 pm, nojb <n...@uchicago.edu> wrote:
<snip>
> Check the literature on lambda lifting. Although the theory was
> worked out for functional languages, it works for imperative ones,
> too. You need to pass references around rather than values. Function
> pointers generally need to be "fat" i.e. to include references to all
> bound variables.
one doesn't necessarily need fat pointers.
for example, one typical architectures, such as x86, one can instead pass
around a function pointer to an in-memory object, which when called may in
turn call the true function passing the captured variables in addition to
the arguments.
this has the advantage that it can remain C ABI compatible.
> I'm not sure of the problem you are describing. It sounds like you
> are confusing dynamic and static scopes. Lambda lifting makes sense
> only in the context of static scopes. A function F that declares a
> variable X will still declare X in the lifted code. Calls to a
> function G originally nested within F will pass X (or a reference to
> it), and G will accept the reference. If G calls itself recursively,
> it passes the same reference to X it received. Same if it calls a
> nested function H that ultimately calls G.
yeah, I didn't respond originally as I couldn't make much sense of what was
being asked.
I thought mayve something different was being asked, and so left it to
others to try to respond.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.