Re: nested functions

"Tommy Thorn" <tommy.thorn@gmail.com>
6 Sep 2006 17:58:26 -0400

          From comp.compilers

Related articles
[2 earlier articles]
Re: nested functions ian@airs.com (Ian Lance Taylor) (2006-08-30)
Re: nested functions torbenm@app-0.diku.dk (2006-08-30)
Re: nested functions tommy.thorn@gmail.com (Tommy Thorn) (2006-08-30)
Re: nested functions reji_thomas@symantec.com (2006-08-31)
Re: nested functions tommy.thorn@gmail.com (Tommy Thorn) (2006-08-31)
Re: nested functions marcov@stack.nl (Marco van de Voort) (2006-09-06)
Re: nested functions tommy.thorn@gmail.com (Tommy Thorn) (2006-09-06)
Re: nested functions Jatin_Bhateja@mentor.com (Jatin Bhateja) (2006-09-08)
Re: nested functions 148f3wg02@sneakemail.com (Karsten Nyblad) (2006-09-08)
Re: nested functions foobar@nowhere.void (Tommy Thorn) (2006-09-08)
Re: nested functions torbenm@app-3.diku.dk (2006-09-08)
Re: nested functions chris.dollin@hp.com (Chris Dollin) (2006-09-08)
| List of all articles for this month |

From: "Tommy Thorn" <tommy.thorn@gmail.com>
Newsgroups: comp.compilers
Date: 6 Sep 2006 17:58:26 -0400
Organization: http://groups.google.com
References: 06-08-14006-08-144 06-09-008
Keywords: Pascal, code
Posted-Date: 06 Sep 2006 17:58:26 EDT

Marco van de Voort wrote:
> IIRC GPC (Gnu Pascal compiler) uses trampolines too. I can't remember
> the exact details, but afaik the main reason had to do with passing
> nested procs to other procedures. Some code to explain:


I don't know GPC, but I'm sure you're right. However they don't _have_
to do it this way.


Trampolines may in fact be the best choice if you expect most
functions passed by argument to *not* have a local environment (such
as global "outer" functions). The obvious alternative is to pass a
pointer to a structure which includes the local environment [pointer]
as well as a pointer to the function. This is better if the opposite
is true.


Either way works for Pascal and GPC in particular and both require a
similar amount of work in the compiler. However trampolines may make
it possible to pass C functions as arguments as well.


Tommy



Post a followup to this message

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