Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!necntc!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.std.c Subject: Re: the logical xor operator! Message-ID: <4794@haddock.ISC.COM> Date: 28 Jun 88 17:28:32 GMT References:<1719@ogcvax.ogc.edu> <1309@ark.cs.vu.nl> <1310@ark.cs.vu.nl> <3254@rpp386.UUCP> <1312@ark.cs.vu.nl> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 42 Let's leave the political discussions in a different newsgroup, okay? In article <1312@ark.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: >Karl W. Z. Heuer writes: >>"Why wasn't logical xor added to ANSI C?". The answer is that it isn't >>useful enough to be worth the change to the language. > >Well, it's strange K&R didn't think of it in the first place... "Why didn't K&R make a logical xor operator?" is a different question. I'll be glad to take this up in comp.lang.c after I return from vacation. >Furthermore, it can be implemented WITHOUT breaking existing code, This (or a weakened form of it) is a necessary condition for ANSI acceptance, but it is not sufficient. >and (admittedly) sometimes one would wish for ^^; but then again: isn't Karl >having problems himself to get \c accepted by ANSI? :-) It's hard to get anything new accepted by X3J11. This is as it should be. Do you want this operator just for completeness, or do you think you'd actually use it a lot? I can only think of one routine I've ever written in which I've needed a logical xor, and since both operands were boolean I simply used "^". >>(and I hold the opinion that nothing else [but a normalized boolean] should >>be handed to a logical operator) > >Come on Karl, what's so terrible about the following common practice? > if (some_pointer && ...) { ... } Well, since you asked: The problem with it is that, by looking at this code fragment in isolation, it's not obvious that some_pointer is a pointer, rather than an integer, a character, a real, or a boolean. If you explicitly write if (p != NULL && i != 0 && c != '\0' && r != 0.0 && b) { ... } the reader has more information, which often makes the code more readable. As I said, this is my personal opinion; I certainly don't think that the language should be changed to enforce it. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint