Path: utzoo!mnetor!uunet!husc6!necntc!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: == vs = Message-ID: <2644@haddock.ISC.COM> Date: 19 Feb 88 17:53:47 GMT References: <11523@brl-adm.ARPA> <909@micomvax.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 26 In article <909@micomvax.UUCP> ray@micomvax.UUCP (Ray Dunn) writes: >To others who suggest defining "EQUALS" etc for "==". This is not a >solution. The problem is not with the use of "==", the problem is with the >use of "=". The solution *has* to involve the "=" operator. If you don't mind the verbosity, you could define "ASSIGN" for "=". >It unfortunately cannot be solved without breaking existing code - although >only to the extent that syntax errors would be given on existing code by >"new" compilers. Well, it doesn't need to be an outright error -- as I mentioned previously, a warning would do it. >The "best" solution suggested so far was to disallow "=" in the context of >the conditional expression of an if statement, and substitute some other >operator, say ":=" (but not necessarily). It's not necessary to create a new operator. If "=" is disallowed in a boolean context, you can write "if ((x = y) != 0)" to get the same effect. It also makes the code more understandable, if you explicitly compare against whichever of { 0, '\0', 0.0, NULL } is appropriate. Btw, the correct spelling is "ANSI", not "ANSII". Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint