Excessive optimization (was Re: what was VMS/OpenVMS written in?)

Chuck Guzis cclist at sydex.com
Thu Dec 2 17:57:53 CST 2010

On 2 Dec 2010 at 18:31, schoedel at kw.igs.net wrote:

> In the 1975 _C Reference Manual_ it looks like this:
>   Any or all of the expressions may be dropped. A missing expression-2
>   makes the implied while clause equivalent to "while( 1 )"; other
>   missing expressions are simply dropped from the expansion above.
> C99 phrases it, in, as:
>   An omitted expression-2 is replaced by a nonzero constant.

In particular the null expression-2 construct is useful when a loop 
contians a non-null initializer and an increment, but the termination 
condition isn't known until the inside of the loop.  For example:

	for ( j = 0, i = 0;;i++)
		j =  thisfunc(i,j);
		if ( somefunc(j))

On the other hand, there's no requirement that the initialization, 
test and increment expressions be remotely related.

C's for() is comparatively straightforward.  Other languages (e.g. 
COBOL PERFORM) have much more varied iteration statements.

Was it Dennis Ritchie who ran the C language list on usenet sometime 
around 1981 or so?  He'd post little puzzles that asked the question 
"What does this code do?".  There were several problems for which the 
answer was "I don't know--it depends on the implementation".  


More information about the cctalk mailing list