[comp.lang.c] The Shape of Assignments to Come, was Re: Assignment in test: OK?

datanguay@watmath.waterloo.edu (David Adrien Tanguay) (09/14/90)

In article <BURLEY.90Sep12073323@world.std.com> burley@world.std.com (James C Burley) writes:
|I doubt anyone could seriously disagree with an argument that it would have
|saved much unnecessary debugging effort if, from the beginning, K&R had
|realized that making "=" an assignment OPERATOR (thus allowing it to work as
|an operator inside an expression) was a mistake -- it meant they had to make
|"==" the comparison operator, which no other language I know of ever had to,
|because others do not allow assignment as an operator.  Given that most people
|would at one point or another accidentally use "=" instead of "==", it would
|have been great (20-20 hindsight) if they'd realized this from the beginning
|and made ":=" or some such thing the assignment operator, leaving "=" out of
|the picture.  Perhaps C fanatics will disagree with this, but I don't take
|seriously people who essentially would say "no, '=' is Right because I'm used
|to it" when I'm saying if it had been ':=' from the beginning, THAT is what
|we'd all be used to, without having to have gone through RUN-time debugging
|to find our early mistakes.  (We'd find most or all of these kinds of bugs at
|compile time.)

C inherited the =/== operators from B. C was designed before the world was
Pascalized, when Fortran was the dominant language. Since Fortran uses =
for assignment, you would need a pretty good reason to switch. Given that
they were already B programmers, they were probably quite comfortable
with =/==. Changing = to := would have been bucking the status quo (Fortran
vs. Algol, Fortran wins), and there was no knowable problem with mistaking
= with ==, since = didn't suggest "test for equality" in their eyes.
(And at 110 baud, or on teletypwriters, you have lots of time to stare at
your code.) To know that there would be a problem, they would have had to
predict that there would be legions of programmers trained to see = as
"equality test".

On the other hand, maybe it was just an attempt at job security...
-- 
David Tanguay            Software Development Group, University of Waterloo