Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: Ivan Godard Newsgroups: comp.compilers Subject: Re: How to type braces for computed gotos Date: Fri, 18 Jul 2014 21:59:05 -0700 Organization: A noiseless patient Spider Lines: 48 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-07-036@comp.compilers> References: <14-05-013@comp.compilers> <14-07-033@comp.compilers> <14-07-035@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: miucha.iecc.com 1405784075 53689 2001:470:1f07:1126:0:676f:7373:6970 (19 Jul 2014 15:34:35 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Sat, 19 Jul 2014 15:34:35 +0000 (UTC) Keywords: code, history, comment Posted-Date: 19 Jul 2014 11:34:35 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com X-Received-Bytes: 3033 X-Received-Body-CRC: 2235663805 Xref: csiph.com comp.compilers:1326 On 7/18/2014 7:21 PM, glen herrmannsfeldt wrote: > federation2005@netzero.com wrote: > > (snip) > >> There is one feature the compiler tests for that I assume the language also >> has in it that I haven't seen much of before: the computed goto. Mary2 had typed labels, that mimicked the common assembler practice of loading a value to a register and jumping to the code that used it. Thus "label int32 eat1;" declared a label variable in which the carried data was an int32. This made use of the Mary2 lack of operator precedence and strict left-to-right evaluation. The "current operand" was the result of evaluating everything to your left, and it formed the left operand of the operation immediately to your right. The carried value of the goto replaced the current operand of the expression containing the label. Thus: if pred() then a[i] + 1 go eat1; ...; x-y*z eat1: *2 =: w; If pred() is true then the execution is: a[i]+1*2=:w; while if false it is: x-y*z*2=:w; Note the absence of precedence; that last turns into asm: load x load y sub load z mul con 2 mul store w or register machine equivalent. The notion of "current operand" and the ability for control flow to carry data was surprisingly useful, primarily because it permitted loops to be value-yielding, as is appropriate in an expression language like Mary. As a result, search loops did not need extraneous variables to hold the value found for use after the loop. The actual goto form was uncommon, but where appropriate it greatly simplified the code and improved readability, and the result engendered a style that was vaguely reminiscent of continuation-passing style. One-pass compilation was near-trivial. [Fortran had assigned goto, and Cobol had ALTER, but that still doesn't mean it was a good idea. -John]