Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #1326
| From | Ivan Godard <ivan@ootbcomp.com> |
|---|---|
| Newsgroups | comp.compilers |
| Subject | Re: How to type braces for computed gotos |
| Date | 2014-07-18 21:59 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <14-07-036@comp.compilers> (permalink) |
| References | <14-05-013@comp.compilers> <14-07-033@comp.compilers> <14-07-035@comp.compilers> |
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]
Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Best "simple" C Compiler I've ever seen andrewchamberss@gmail.com - 2014-05-04 18:23 -0700
Re: Best "simple" C Compiler I've ever seen federation2005@netzero.com - 2014-06-30 12:42 -0700
How to type braces for computed gotos (was: Best "simple" C Compiler I've ever seen) federation2005@netzero.com - 2014-07-18 14:44 -0700
Re: How to type braces for computed gotos glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-07-19 02:21 +0000
Re: How to type braces for computed gotos Ivan Godard <ivan@ootbcomp.com> - 2014-07-18 21:59 -0700
Re: How to type braces for computed gotos federation2005@netzero.com - 2014-07-21 10:32 -0700
Re: How to type braces for computed gotos (was: Best "simple" C Compiler I've ever seen) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-07-21 11:45 +0000
Re: How to type braces for computed gotos glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-07-21 16:19 +0000
Re: How to type braces for computed gotos wclodius@earthlink.net (William Clodius) - 2014-07-21 21:44 -0600
Re: How to type braces for computed gotos glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-07-23 00:35 +0000
Re: How to type braces for computed gotos wclodius@earthlink.net (William Clodius) - 2014-07-22 22:36 -0600
Re: How to type braces for computed gotos anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-07-25 22:38 -0400
csiph-web