Assignment in test: OK?

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Thu Sep 13 07:22:48 AEST 1990


In article <18326 at ultima.socs.uts.edu.au> jeremy at sinope.socs.uts.edu.au (Jeremy Fitzhardinge) writes:
> >> BTW, if I ever write a new C-like language, ":=" will be the assignment
> >> operator, "==" the comparison operator, and "=" totally invalid!  Although
> If you are going to prevent assignment in a conditional, you are preventing
> it from being an expression.  This stops things like "a=b=c=0;" from falling
> out elegantly.

Q has == for comparison, = for assignment with no value, and := for
assignment with a value. (Among others.) So ``a = b'' still works,
``if (a = b)'' is illegal, and the compiler can check all statements
for unused values. The only correct code that has to be rewritten is
``a = b = c = d'' (as ``a = b := c := d'') and a proper ``if (a = b)''
(as ``if (a := b)'').

Followups to alt.lang.cfutures.

---Dan



More information about the Comp.lang.c mailing list