Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.misty.com!news.iecc.com!.POSTED!nerds-end From: glen herrmannsfeldt Newsgroups: comp.compilers Subject: Re: Is multi-level function return possible? Date: Fri, 14 Mar 2014 21:47:05 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 37 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-03-037@comp.compilers> References: <14-03-020@comp.compilers> <14-03-022@comp.compilers> <14-03-031@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: miucha.iecc.com 1394834512 77047 2001:470:1f07:1126:0:676f:7373:6970 (14 Mar 2014 22:01:52 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Fri, 14 Mar 2014 22:01:52 +0000 (UTC) Keywords: Pascal, history, comment Posted-Date: 14 Mar 2014 18:01:51 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:1159 George Neuner wrote: > On Tue, 11 Mar 2014 13:04:57 GMT, anton@mips.complang.tuwien.ac.at > (Anton Ertl) wrote: >>... 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 >>feature of the language, and Wirth removed it (along with goto) from >>his later languages. > Interesting. I was not aware of this, and it is not mentioned in any > of several Pascal books I have from the early 80's. Other than > Wirth's own, I wonder how many implementations actually allowed it? As I remember it, Pascal allows GOTO out of an internal procedure. That might not look so significant in the book, but, especially in the case of recursion, it gets interesting when you have to implement it. Some of the programs that go along with TeX use it, I believe DVItype being one. Some years ago, I translated one to C, and so used longjmp() for the first, and probably last, time. (That was not so long after I started working with C.) TeX and associated programs were originally all in Pascal, but using Knuth's preprocessor to make them more readable, what he calls Literate Programming. Among other features that he discusses, is that Pascal GOTO uses numeric labels, apparently to discourage their use. Part of Literate Programming is to use alphanumeric, more descriptive labels. But as with many GOTO statements, the usual use is getting out in the case of a fatal error, even from nested procedure calls. In addition to what Pascal allows, C's longjmp() and PL/I with LABEL variables, allow run-time selection of targets. That is, with a variable instead of a compile-time constant label. -- glen [I thought the numeric labels were to look like Fortran. -John]