== vs =
Frank Adams
franka at mmintl.UUCP
Wed Mar 30 05:40:58 AEST 1988
In article <1390 at eneevax.UUCP> noise at eneevax.umd.edu.UUCP (Johnson Noise) writes:
> I'm curious, is there anyone other than Ray Dunn that does
>not like = and == ?
Let me restate my opinion.
I want to keep = and == with almost exactly the same syntax as they have
now. The only difference is that = does not have as its value the result of
the assignment; instead its value is void. A new operator, perhaps :=,
should be introduced, which has exactly the definition that = has now.
(However, I would expect a good compiler to complain if the result of the
operator is not used, something which cannot (reasonably) be done with the
current syntax.
This means:
(1) We still have the simple, one character operator for the common case.
This *is* important.
(2) If one miswrites = when one means ==, one gets an error message.
(3) The proposal cleans up the semantics by eliminating the category of
expressions with a non-void type whose value is commonly ignored. (Mostly
-- there still may be functions returning values which are commonly
ignored.) This means that a strict compiler can check that a value is used
if and only if it is not void. (Casting to void is, of course, permitted.)
This could actually be introduced into C over a period of years. The first
step is to introduce the new assignment operator, continuing to support use
of the result of an = assignment as an obsolete feature. At some later
point, this could be phased out.
In any event, I would like to see something like this in D (if that ever
happens).
--
Frank Adams ihnp4!philabs!pwa-b!mmintl!franka
Ashton-Tate 52 Oakland Ave North E. Hartford, CT 06108
More information about the Comp.lang.c
mailing list