Assignment in test: OK?

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Thu Sep 20 05:49:59 AEST 1990


In article <859 at jonlab.UUCP> jon at jonlab.UUCP (Jon H. LaBadie) writes:
> BTW Dan, I think it should be yield, or evaluate to, a value, not
>          return a value.

Not if you don't distinguish between operators and functions.

> One of the many virtues of C is that assignment IS an operator and
> DOES yield a value.

Right. That's why you need to preserve that function, as :=. But
changing the common = to not return a value will not affect 99% of the
lines in a typical program, and it will catch the beginner's if (a = b).

> This part of the language is not broken, don't try to fix it.

You're taking entirely the wrong attitude. If beginners slip up
regularly on a language feature, and there's a straightforward way to
change the feature, then the feature should be changed (at least in
future languages). Just because you and I don't make a particular
mistake doesn't mean the language shouldn't prevent the mistake.

Furthermore, =/:=/== has an important benefit: The code-checker no
longer needs to special-case a = b when it's looking for ignored values.

The distinction between = and := is entirely logical, would eliminate
one source of frustration everywhere, and helps the compiler. What more
do you want?

---Dan



More information about the Comp.lang.c mailing list