== vs =

Thomas Truscott trt at rti.UUCP
Thu Feb 4 02:08:32 AEST 1988


> My conclusion: if = had been chosen for the equality operator and any two
> character symbol (e.g. ::) had been chosen for the assignment operator, the
> cost of developing a program in C would be less even though the character
> count in a program might be 0.5% greater.
>      Marv Rubinstein -- Interactive Systems

The cost of developing a C program would be even less
if the compiler (and of course lint) simply pointed out
such possible mistakes.

No matter what symbols are used for operators,
programmers will occasionally use the wrong one.
	Compilers should warn of possible mistakes such as:
		if (x = y) foo();	/* :: would be just as dubious */

No matter how well-designed one's indenting style,
programmers will occasionally make indenting mistakes.
	Compilers should warn of dubious indentations, such as:
		while (foo() > 0);
			bar();

No matter how clever the operator precedence,
programmers will occasionally get unintended precedence.
	Compilers should warn of hazardous operator usage, such as:
		i = 1<<n - 1;

I do not want special purpose programs to check for these or to rewrite
the code.  And I strongly prefer these checks to be in the compiler
as well as in lint, if only to cut down on the flood of simple
programming mistakes that are posted to this newsgroup.
(I also think that the cc/lint business needs to be reconsidered.)

C compilers already have dozens of warning messages,
and they have saved programmers much grief.
I see no big issues here, just the details of for what to issue warnings,
how to phrase them, and (if it is warranted) how to suppress them.
The absence of appropriate warnings is a bug, whether in cc or lint,
and should be reported as such.
	Tom Truscott



More information about the Comp.lang.c mailing list