Precedent for use of =

kelem at aero2.arpa kelem at aero2.arpa
Sat Jun 14 04:37:27 AEST 1986


There is a 429 year precedent of using the symbol = for equality.

The original rationale for using = for equality was given by Robert Recorde
in 1557.
The explanation was "... to auoide the tediouse repetition of these woordes:
is equalle to: I will sette as I doe often in woorke vse,
a paire of paralleles, or Gemowe lines of one lengthe, thus:
=, {a very long equals sign} bicause noe .2. thynges, can be moare equalle."

Granted, spelling is not the same, but = has served as equals in Mathematics 
for centuries.  Fortran changed the meaning of = to assignment and equality
was spelled ".EQ.".  Algol 60 reverted to = for equality and used ":=" for
assignment.  This convention was followed by some of its successors: Algol 68,
Pascal, and Ada.  PL/I used = for both assignment and equality so that one
could write confusing statements like " a = b = c; " (compare b with c and
assign to a).

The argument put forth in Kernighan and Ritchie is:
"Since assignment is about twice as frequent as equality testing in typical
C programs, it's appropriate that the operator be half as long."

1.  There are over four centuries of mathematics using = for equals.
Using = to mean assignment is begging for confusing code.
2.  Assignment is a relatively new concept and a new notation is warrented.
":=" has enough precedent to serve this purpose.

Is it really worth using a notation that is contrary to that of the more
universal mathematics, and thus guaranteed to confuse novices and catch pros
off-guard in order to type "=" instead of ":="?  I think adding a few
characters to improve readability and understandability is worth the
time and effort.

Consequently, I wrote a pre-processor for C called ac68 that uses := for
assignment, = for equality, and has all the cumulative operators in the
style of Algol 68: +:=, -:=, *:=, &:=, <<:=, etc.  Unfortunately, the C
and dbx messages refer to the operators that get generated.  Still, the
code is a lot more readable.



More information about the Comp.lang.c mailing list