Re: Is multi-level function return possible?

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

          From comp.compilers

Related articles
Is multi-level function return possible? noitalmost@cox.net (noitalmost) (2014-03-10)
Re: Is multi-level function return possible? kaz@kylheku.com (Kaz Kylheku) (2014-03-11)
Re: Is multi-level function return possible? anton@mips.complang.tuwien.ac.at (2014-03-11)
Re: Is multi-level function return possible? gneuner2@comcast.net (George Neuner) (2014-03-11)
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)
[28 later articles]
| List of all articles for this month |

From: Kaz Kylheku <kaz@kylheku.com>
Newsgroups: comp.compilers
Date: Tue, 11 Mar 2014 22:15:36 +0000 (UTC)
Organization: Aioe.org NNTP Server
References: 14-03-020 14-03-022
Keywords: code, Pascal
Posted-Date: 12 Mar 2014 23:05:43 EDT

On 2014-03-11, Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
> noitalmost <noitalmost@cox.net> writes:
>>Is this a doable thing for a Pascal-like language that is meant to be
>>compiled? I have a multi-level break which works within a procedure, but the
>>return across procedure boundaries seems to add a lot of complications.
>
> Yes, in Pascal you can goto a label that is in a containing procedure
> or function, even across several levels. That is a very rarely used


I.e. you can jump out of a "downward funarg" closure in that original Pascal,
back to the parent environment, just like in Lisp.


> feature of the language, and Wirth removed it (along with goto) from
> his later languages.


Then Cardelli added lexically scoped symbol macros to Modula-3, not
unlike (symbol-macrolet ...) in the form of the new, improved version
of the WITH statement.


Maybe one day these Pascalites will assemble a complete language that
has everything at the same time.




> The more common feature is to have exceptions that you can throw and
> that can be caught in a function/procedure/method several levels
> further out.
>
> The difference between these languages features is that Pascal's goto
> is statically scoped, whereas exceptions are dynamically scoped.


But if Pascal had upward funargs (closures that can be returned from the scope
in which they are created), then the goto, though lexically scoped, would have
have a test to detect that its target is no longer in the dynamic scope.


I.e. it's not really purely lexical. Resolving the label identifier is lexical,
but the situation is dynamic.


Also, never mind full closures: consider the situation that the function is
simply recursive.


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?


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.)


Post a followup to this message

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