Re: Is multi-level function return possible?

Hans-Peter Diettrich <DrDiettrich1@aol.com>
Thu, 27 Mar 2014 01:58:48 +0100

          From comp.compilers

Related articles
[29 earlier articles]
Re: Is multi-level function return possible? anton@mips.complang.tuwien.ac.at (2014-03-24)
Re: Is multi-level function return possible? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2014-03-24)
Re: Is multi-level function return possible? gneuner2@comcast.net (George Neuner) (2014-03-26)
Re: Is multi-level function return possible? news@cuboid.co.uk (Andy Walker) (2014-03-26)
Re: Is multi-level function return possible? news@cuboid.co.uk (Andy Walker) (2014-03-26)
Re: Is multi-level function return possible? federation2005@netzero.com (2014-03-26)
Re: Is multi-level function return possible? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2014-03-27)
Re: Is multi-level function return possible? monnier@iro.umontreal.ca (Stefan Monnier) (2014-04-07)
| List of all articles for this month |
From: Hans-Peter Diettrich <DrDiettrich1@aol.com>
Newsgroups: comp.compilers
Date: Thu, 27 Mar 2014 01:58:48 +0100
Organization: Compilers Central
References: 14-03-020 14-03-022 14-03-025 14-03-030 14-03-044 14-03-046 14-03-047 14-03-048 14-03-053 14-03-057 14-03-060
Keywords: symbols, history, comment
Posted-Date: 26 Mar 2014 21:30:53 EDT



George Neuner schrieb:


> The instruction cost is slightly greater to maintain a display than to
> maintain a static chain, but if the display is in suitably fast memory
> - in registers or locked into cache - the actual difference in *time*
> spent on maintenance may be insignificant.


Many years ago I found a funny implementation of local variables in
GfA-Basic. As opposed to most (all?) other compilers, on entry of a
subroutine the *global* variables; matching the name of a local
variable or parameter; were pushed onto the stack and re-initialized
for use inside the subroutine, and restored on exit. This allows to
access all currently living variables from everywhere in the code. It
also allows for by-name references when the table of variables is
prepared accordingly, as was the case in traditional Basic. Dunno how
Algol implemented this and its many other exotic parameter passing
conventions.


I found that implementation so exciting, that I think it's worth to be
mentioned here.


DoDi
[That's approximately what Lisp calls shallow binding. For Algol60
call by name, which was a mistake, it needed the Pascal display or the
equivalent, and arguments had to be callback routines (thunks) to
allow them to recompute the expression values. -John]


Post a followup to this message

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