new do-while syntax
Peter da Silva
peter at ficc.uu.net
Wed Dec 21 01:43:09 AEST 1988
In article <8562 at alice.UUCP>, ark at alice.UUCP (Andrew Koenig) writes:
> As I said before, it's way too late to get anything like this
> into C now. It's fun to think about, though.
Is it? Petition your compiler writer. It should be a completely safe and
transparent extension to the existing syntax. The following should all
be valid:
do ... while(x); /* existing do/while, null while expr */
while(x) ... /* existing while, null do expr */
do ... while(x) ... /* full do/while */
The yaccoid BNF would be (since ";" is a valid statement):
dowhile : do WHILE(expr) statement
;
do : /* nothing */
| DO statement
;
If you can get a few compiler writers to put this in, it'll have a chance
of making it to the next version of 'C'. It reduces the complexity of the
language, too... replaces three constructs (do, while, and for) with one.
(yes, I am aware of the 'continue' problem, and I'm not suggesting removing
the for statement).
In fact, this could be declared an "editorial change" if you have the
brass.
--
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Work: uunet.uu.net!ficc!peter, peter at ficc.uu.net, +1 713 274 5180.
Home: bigtex!texbell!sugar!peter, peter at sugar.uu.net.
More information about the Comp.lang.c
mailing list