|Best "simple" C Compiler I've ever seen email@example.com (2014-05-04)|
|How to type braces for computed gotos (was: Best "simple" C Compiler I firstname.lastname@example.org (2014-07-18)|
|Re: How to type braces for computed gotos (was: Best "simple" C Compil email@example.com (2014-07-21)|
|Re: How to type braces for computed gotos firstname.lastname@example.org (glen herrmannsfeldt) (2014-07-21)|
|Re: How to type braces for computed gotos email@example.com (2014-07-21)|
|Re: How to type braces for computed gotos firstname.lastname@example.org (glen herrmannsfeldt) (2014-07-23)|
|Re: How to type braces for computed gotos email@example.com (2014-07-22)|
|Re: How to type braces for computed gotos firstname.lastname@example.org (2014-07-25)|
|From:||email@example.com (Anton Ertl)|
|Date:||Mon, 21 Jul 2014 11:45:41 GMT|
|Organization:||Institut fuer Computersprachen, Technische Universitaet Wien|
|Keywords:||C, Fortran, history|
|Posted-Date:||21 Jul 2014 10:10:41 EDT|
>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. What's I
>don't quite understand how the branches are being typed. A computed goto
>inside a void routine has the branches typed (void *), with the individual
>items accessed in effect as references to (void *).
>The branches are essentially continuations. So the question here is how are
>continuations being typed. From the example used in the distribution, either
>(A) all continuations are typed (void *) or they are being typed (T *) when
>they occur inside a function that returns type T.
I guess this compiler implements the labels-as-values extension of GNU
C (aka "computed goto", but see the Fortran note below). The type of
a label is always void *; static typing fans might prefer a separate
label type (or a whole type system for labels), but I guess that the
intersection between static typing fans and the users of this
extension is very small. I have used labels-as-values extensively and
I have not produced errors stemming from confusion between labels and
other occurences of void *.
BTW, in Fortran this feature is called "assigned goto", and it uses
integer variables (i.e., not a special type, either) for storing the
labels (and therefore needs a separate syntax "assign 50 to l" instead
of just writing "l=50"). Fortran also has a feature called "computed
goto", but that is closer to a C switch than a GNU C "goto *".
M. Anton Ertl
Return to the
Search the comp.compilers archives again.