PRECEDENT FOR USE OF =

emjej at uokvax.UUCP.UUCP emjej at uokvax.UUCP.UUCP
Fri Jul 11 00:08:00 AEST 1986


/* Written  8:15 pm  Jul  3, 1986 by MEYER at RADC-TOPS20.ARPA in net.lang.c */
     I know this is going to cause a bit more of a stir here, here goes.

Everybody keeps guessing at the reasons for the use of = for asignment
and == for equality tests.  How about a different angle: how many times
in a program do you assign something versus how many times you compare things?
/* End of text from net.lang.c */

If that's a reasonable principle of programming language design, then
let's see if we can't get Huffman-coding for C keywords in the next ANSI
draft standard.

= for assignment is one of many flaws in C syntax.  Combined with the
absence of a Boolean type, it is a considerable source of errors in C
code.  Lint should warn the user of every occurrence of "if (a = b)".

(I predict that at least one C-worshipper will say "*real* C programmers,
as opposed to quiche-eaters, don't make that mistake."  I think they're
wrong, based on the instances of it I've seen.  Second-order comment
will be "you haven't done a study, so you're not worth bothering with":
I admit that I haven't, but (1) I lack the resources, and (2) it's too
bad the designers of programming languages (and Unix utilities) don't
have to do human factors studies before introducing their products.)

					James Jones



More information about the Comp.lang.c mailing list