Re: Is multi-level function return possible?

George Neuner <gneuner2@comcast.net>
Fri, 14 Mar 2014 02:39:28 -0400

          From comp.compilers

Related articles
[4 earlier articles]
Re: Is multi-level function return possible? lkrupp@pssw.com (Louis Krupp) (2014-03-11)
Re: Is multi-level function return possible? kaz@kylheku.com (Kaz Kylheku) (2014-03-11)
Re: Is multi-level function return possible? tkowaltowski@gmail.com (Tomasz Kowaltowski) (2014-03-12)
Re: Is multi-level function return possible? anton@mips.complang.tuwien.ac.at (2014-03-13)
Re: Is multi-level function return possible? yaldnif.w@blueyonder.co.uk (Bill Findlay) (2014-03-14)
Re: Is multi-level function return possible? ivan@ootbcomp.com (Ivan Godard) (2014-03-13)
Re: Is multi-level function return possible? gneuner2@comcast.net (George Neuner) (2014-03-14)
Re: Is multi-level function return possible? gneuner2@comcast.net (George Neuner) (2014-03-14)
Re: Is multi-level function return possible? marcov@toad.stack.nl (Marco van de Voort) (2014-03-14)
Re: Is multi-level function return possible? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2014-03-14)
Re: Is multi-level function return possible? kaz@kylheku.com (Kaz Kylheku) (2014-03-14)
Re: Is multi-level function return possible? kaz@kylheku.com (Kaz Kylheku) (2014-03-14)
Re: Is multi-level function return possible? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2014-03-14)
[23 later articles]
| List of all articles for this month |
From: George Neuner <gneuner2@comcast.net>
Newsgroups: comp.compilers
Date: Fri, 14 Mar 2014 02:39:28 -0400
Organization: A noiseless patient Spider
References: 14-03-020 14-03-022 14-03-025
Keywords: code, design
Posted-Date: 14 Mar 2014 13:36:55 EDT

On Tue, 11 Mar 2014 22:15:36 +0000 (UTC), Kaz Kylheku
<kaz@kylheku.com> wrote:


>Recursion means there is possibly more than one activation of the environment
>which contains the target label of the goto. Which activation is chosen as the
>jump target? Does the goto return to the same recursion level in which
>the closure was created or does it just find the innermost activation of
>that label?


YMMV, but ISTM that recursion is not really relevant to the issue:
lexical scoping by itself introduces the potential for name shadowing
and the rule always has been to reference the instance which is
defined "closest" to the point of use. The addition of recursion
simply makes locating that closest instance - at least in part - a
runtime operation rather than a compile time operation.


We can argue about whether the type should be part of the name: e.g.,
if x:string shadows x:integer then does an arithmetic operation on x
find x:integer or does it fail for incompatible types? But this is a
discussion at a different level.




>If the closure jsut goes to the innermost block which has the label,
>then the target resolution is in fact dynamically scoped, even though
>the label is lexical. (Because the target block is not lexically captured
>along with the closure, but chosen just from whatever is visible at the
>time the goto takes place.)


Your Lisp is showing 8-) ... "nested function" is not synonymous with
"closure".


Standard Pascal did have not have closures: you could pass a function
by name as an argument to another, but its definition had to be
visible both at the point of passing the name and at the point of
invocation [through the aliasing argument].


Various extended Pascals have provided function types and function
pointers - mostly with the caveat that the pointers could be used only
where their function definition was visible. GPC, however, has
implemented real closures: AFAIK they can passed only by name and not
stored, but they have dynamic extent and can be invoked where they are
not visible lexically.


George


Post a followup to this message

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