Assignment in test: OK?
Richard A. O'Keefe
ok at goanna.cs.rmit.oz.au
Fri Sep 21 17:19:35 AEST 1990
In article <4641:Sep1919:49:5990 at kramden.acf.nyu.edu>, brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:
> 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).
...
> Furthermore, =/:=/== has an important benefit: The code-checker no
> longer needs to special-case a = b when it's looking for ignored values.
I'm getting sick of this. If you want a language which has no = / ==
problem, Scheme, with its
(set variable value) ;; assignment
(eq? thing1 thing2) ;; object identity
is hard to beat. And there's a free compiler from DEC that turns it into
C. (Best of all, none of those nasty malloc/free errors.) But it doesn't
look like C? Neither it does. Wasn't that the point?
There's a _lot_ that C compilers could usefully warn about (like
uninitialised variables, dead code, *ptr - *ptr++, and so on). = -vs- ==
is just one case among many.
--
Heuer's Law: Any feature is a bug unless it can be turned off.
More information about the Comp.lang.c
mailing list