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) |
[26 later articles] |
From: | Louis Krupp <lkrupp@pssw.com> |
Newsgroups: | comp.compilers |
Date: | Tue, 11 Mar 2014 15:16:46 -0600 |
Organization: | Compilers Central |
References: | 14-03-020 |
Keywords: | code, C++ |
Posted-Date: | 12 Mar 2014 23:04:45 EDT |
On Mon, 10 Mar 2014 15:46:31 -0400, noitalmost <noitalmost@cox.net>
wrote:
>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.
>
>I don't recall this being discussed in the dragon book, perhaps because it's
>just a silly idea. But implementing the multi-level break got me curious
>whether it's possible.
>[Sure, you can do it. PL/I let you jump out of a routine and I think Algol60
>may have, too. You just need to keep your stack frames sufficiently linked
>so that you can find the one you want and unwind everything below it. Look
>at the way Algol and Pascal reference variables in blocks outside the current
>routine and you'll get most of what you need. -John]
What you're looking for sounds similar to the setjmp/longjmp feature
in C and exception handling in C++. If you're going to attract C++
users to your language, the try/catch block would be a good thing to
imitate.
Unisys ALGOL has a TRY statement; see
http://public.support.unisys.com/aseries/docs/clearpath-mcp-15.0/pdf/86000098-511.pdf
for details.
I believe that exception handling as it's usually implemented is
driven by the calling routine, while it sounds like what you want is
for a nested procedure to return from an outer procedure. Unisys
ALGOL does at least some of this with a "bad" GO TO statement, which
branches out of one or more blocks. If an outer procedure END
statement has a label, and if you branch to it from within a contained
procedure, you've accomplished your multi-level return.
Louis
Return to the
comp.compilers page.
Search the
comp.compilers archives again.