Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.ripco.com!rahul.net!wasp.rahul.net!rahul.net!news.misty.com!news.iecc.com!.POSTED!nerds-end From: noitalmost Newsgroups: comp.compilers Subject: Re: Is multi-level function return possible? Date: Sat, 15 Mar 2014 12:21:52 -0400 Organization: Compilers Central Lines: 50 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-03-043@comp.compilers> References: <14-03-020@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit X-Trace: miucha.iecc.com 1394992966 32933 2001:470:1f07:1126:0:676f:7373:6970 (16 Mar 2014 18:02:46 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Sun, 16 Mar 2014 18:02:46 +0000 (UTC) Keywords: code, Pascal, comment Posted-Date: 16 Mar 2014 14:02:46 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:1165 On Tuesday, March 11, 2014 09:04:57 AM Anton Ertl wrote: > 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 > feature of the language, and Wirth removed it (along with goto) from > his later languages. I had to go look that up. Yep, it's there in the ISO standard, as one of the uses of goto. This is kind of like what I had in mind. I was thinking of a prettier syntax, though: procedure f() : procedure g() int : procedure h() : return from g 3; end h; h(); nope(); # doesn't get called end g; x : int; x := g(); print x; # prints 3 end p; The syntax meshes nice with my break stmt: while {outer} x < 10 : loop : break from outer; end; end; It's a lot more restrictive than exeptions, and I'm not sure if has any use, but it looks nice :) The only potential use that comes to mind is: procedure p() : procedure r() : cond : bool; # some condition break from r if cond; r(); end r; end f; f(); The break would cause a quick exit by blowing away all the intervening stack frames from the recursive calls to r. I'm assuming I can implement this without too much trouble, since it could be done in Pascal. Is that true? [I would think so. See the next message. -John]