Related articles |
---|
Best "simple" C Compiler I've ever seen andrewchamberss@gmail.com (2014-05-04) |
How to type braces for computed gotos (was: Best "simple" C Compiler I federation2005@netzero.com (2014-07-18) |
Re: How to type braces for computed gotos gah@ugcs.caltech.edu (glen herrmannsfeldt) (2014-07-19) |
Re: How to type braces for computed gotos ivan@ootbcomp.com (Ivan Godard) (2014-07-18) |
Re: How to type braces for computed gotos gah@ugcs.caltech.edu (glen herrmannsfeldt) (2014-07-21) |
Re: How to type braces for computed gotos federation2005@netzero.com (2014-07-21) |
Re: How to type braces for computed gotos wclodius@earthlink.net (2014-07-21) |
Re: How to type braces for computed gotos gah@ugcs.caltech.edu (glen herrmannsfeldt) (2014-07-23) |
Re: How to type braces for computed gotos wclodius@earthlink.net (2014-07-22) |
Re: How to type braces for computed gotos anton@mips.complang.tuwien.ac.at (2014-07-25) |
From: | Ivan Godard <ivan@ootbcomp.com> |
Newsgroups: | comp.compilers |
Date: | Fri, 18 Jul 2014 21:59:05 -0700 |
Organization: | A noiseless patient Spider |
References: | 14-05-013 14-07-033 14-07-035 |
Keywords: | code, history, comment |
Posted-Date: | 19 Jul 2014 11:34:35 EDT |
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]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.