What should be added to C

Tainter tainter at ihlpg.UUCP
Sun Jun 1 04:34:00 AEST 1986


> Why not use the Ada style of putting a label before the loop body - it's
> like giving a name to the loop:
> 	complicated_loop: for(;;) {
> 	    {{{{{
> 		break complicated_loop;
> 	    }}}}}
> 	}
> No, it's not really much different from a goto.
> Andy "Krazy" Glew. Gould CSD-Urbana.    USEnet:  ihnp4!uiucdcs!ccvaxa!aglew

It is that little bit different though.  And it is a definate WIN!
When you see a "break <label>" you know the label is on an enclosing block
and not just anywhere as in "goto <label>".
It alsos provides "continue <label>" with little extra cost.
I want BOTH label uses!  But this causes an interpretation problem.
either:

       <label> : for () .....

       becomes ambiguous: labels loop or is freestanding label?
	   You can resolve this by using <label> : ; for() .....
	   as a free standing label.
or:

	<label> : for () .....

	has both meanings: for goto it is free standing(i.e. restarts
	    the loop) and for break/continue it labels the loop.

This should be fairly easy to add to a C derived(*) compiler.

--j.a.tainter (Gods answer to lonely microcomputers)

*  derived because once you starting adding things is it really the same 
   language.   I propose we call this language ceder for C DERived since
   these changes would *spruce* up the language a bit. :-)



More information about the Comp.lang.c mailing list