Assignment in test: OK?

Richard A. O'Keefe ok at goanna.cs.rmit.oz.au
Thu Sep 13 19:51:20 AEST 1990


In article <1990Sep12.194753.9808 at laguna.ccsf.caltech.edu>, bruce at seismo.gps.caltech.edu (Bruce Worden) writes:
> are legal, I don't see how `:=' is any better than just `='.  People who
> are used to thinking of `:=' as `equal' will type it as freely as we 
> type `='.

But there _are_ no people who are used to thinking of ":=" as "equal".
Algol 60, Algol 68, Pascal, Modula, Modula-2, Modula-3, MESA, Ada,
BCPL, ... all use ":=" for assignment.  Is there any well known language
that uses ":=" for equality?  Surely not.

> Only something like Fortran's .EQ. is different enough to 
> draw attention to the two different meanings of `is equal to'.

What "two different meanings"?  Assignment is _not_ a meaning of
"is equal to" and never has been.

> I am not objecting to constructs like:
> 	if((fd=open(path,flags,mode)) != NULL)

You _should_.  Assuming POSIX for open() and ANSI C for NULL,
open() returns an int but NULL may be of type (void *).
The real trouble would come if your C used the other ANSI-blessed
value for NULL, namely 0.  The error value for open() is -1, not 0.
Use
	if ((fd = open(path, flags, mode)) != -1) {
	    ...
	}
-- 
Heuer's Law:  Any feature is a bug unless it can be turned off.



More information about the Comp.lang.c mailing list