nested functions



I have a doubt regarding the nested functions and how the same is
supported in languages. I don't have much knowledge in compilers
except for the occasional reading.

Please correct me if my understanding is wrong.

From my understanding, a compiler uses

1. Lambda lifting where the nested function is hoisted to global level
passing free variables through an env pointer or as explicit arguments.

2.Static chaining or displays which uses pointers to the corresponding
stackframe in which the non local variable is defined.


One of my questions is

whether lambda lifting cannot solve any cases which chaining/displays
can only solve?.

My next doubt is regarding the nested function support from GCC using
trampolines. I could see that in case of function pointers of nested
functions GCC was generating the code on the stack to move the frame
pointer of the function in which the nested function is nested to ECX
and then to do a jump to the nested function.


My question is
Whether GCCs support for nested functions is similar to nested function
support in functional languages like haskell/scheme and do trampolines
provide any advantage other than access time.?

I realise that you cannot return a nested func pointer and pass it
around since theres no way GCC associates state with the ptr.
.



Relevant Pages

  • Nested functions implementation
    ... Lambda lifting where the nested function is hoisted to global level ... passing free variables through an env pointer or as explicit arguments. ... My next doubt is regarding the nested function support from GCC using ... Whether GCCs support for nested functions is similar to nested function ...
    (comp.lang.functional)
  • Re: nested functions
    ... Lambda lifting where the nested function is hoisted to global level ... passing free variables through an env pointer or as explicit arguments. ... 2.Static chaining or displays which uses pointers to the corresponding ...
    (comp.compilers)
  • Re: nested functions
    ... Lambda lifting where the nested function is hoisted to global level ... passing free variables through an env pointer or as explicit arguments. ... So you need to dynamically build a trampoline ...
    (comp.compilers)
  • Re: FAQ 1.12--auto keyword
    ... it is necessary to forward declare a nested function (for ... gcc...I'm not sure if this is gcc specific or a language issue.) ... Standard C doesn't allow nested function definitions. ...
    (comp.lang.c)
  • Re: FAQ 1.12--auto keyword
    ... it is necessary to forward declare a nested function (for ... If gcc allows nested functions, ... if they want to invent a new language, ...
    (comp.lang.c)