Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!mcnc!rti-sel!dg_rtp!throopw From: throopw@dg_rtp.UUCP (Wayne Throop) Newsgroups: net.lang.c Subject: Re: Boolean Operators Slighted in C Message-ID: <345@dg_rtp.UUCP> Date: Thu, 8-May-86 16:36:34 EDT Article-I.D.: dg_rtp.345 Posted: Thu May 8 16:36:34 1986 Date-Received: Sun, 11-May-86 00:32:57 EDT References: <838@ihwpt.UUCP> <778@bentley.UUCP> <12329@ucla-cs.ARPA> Lines: 32 > jimc@ucla-cs.ARPA (Jim Carter) >> kwh@bentley.UUCP (KW Heuer) >>Btw, you can't have *all* operators extended with "=". How would you write >>"v = v < e;"? (Not that it's useful.) > I think it's useful! As written, of course, it's semantically invalid, > but what you really mean is "v <= e" (sic) or, to demonstrate where it's > really useful, > array[horrendous] [subscript] [list] <= bigexpr; > rather than > if (array[h][s][l] < bigexpr) array[h][s][l] = bigexpr; The point is not that it isn't useful to collapse multiple array (or other clumsy) references. The point is that in "e1 = e1 < e2", the "<" operator assumes arguments with numeric semantics and yeilds a value with boolean semantics. Since e1 is both an argument and a result, this expression isn't very meaningful. The fact that C overloads the numeric types with boolean meaning doesn't make this a useful thing to do. Interestingly, if e2 also has boolean semantics, the "e1 < e2" gives the same result as "!e1 && e2" (ignoring side effects). Doesn't seem like a primitive to clammor for in the language, nor does "<" seem like a good symbol for it if it were a primitive. Now, I know what all you hackers are saying. You're saying "But Wayne, how did you become a LOVE GOD?" (What's that? net.lang.c? Not net.panting.singles? Sorry, I mean) "But Wayne, I just don't care diddly about numeric vs boolean type safety debates. I just want something that'll WORK." Ok. Fine. But you'll probably be looking for subtle and disgusting bugs in programs that contain oddities like "e1 = e1 < e2" long after others are happily using working programs that don't. So there. -- Wayne Throop !mcnc!rti-sel!dg_rtp!throopw