nested functions
29 Aug 2006 22:46:50 -0400

          From comp.compilers

Related articles
nested functions (2006-08-29)
Re: nested functions (Tommy Thorn) (2006-08-30)
Re: nested functions (Ian Lance Taylor) (2006-08-30)
Re: nested functions (2006-08-30)
Re: nested functions (Tommy Thorn) (2006-08-30)
Re: nested functions (2006-08-31)
Re: nested functions (Tommy Thorn) (2006-08-31)
[7 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
Date: 29 Aug 2006 22:46:50 -0400
Keywords: code, question
Posted-Date: 29 Aug 2006 22:46:50 EDT

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.

Post a followup to this message

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