Path: utzoo!utgpu!water!watmath!clyde!bellcore!faline!ulysses!allegra!princeton!udel!gatech!mcnc!decvax!decwrl!pyramid!prls!philabs!pwa-b!mmintl!franka From: franka@mmintl.UUCP Newsgroups: comp.lang.c Subject: Re: == vs = Message-ID: <2681@mmintl.UUCP> Date: 23 Jan 88 00:24:45 GMT References: <626@PT.CS.CMU.EDU> <214@oink.UUCP> Reply-To: franka@mmintl.UUCP (Frank Adams) Organization: Multimate International, E. Hartford, CT. Lines: 31 Posted: Fri Jan 22 19:24:45 1988 In article <214@oink.UUCP> jep@oink.UUCP (James E. Prior) writes: >In article <626@PT.CS.CMU.EDU> edw@IUS1.CS.CMU.EDU (Eddie Wyatt) writes: >>The language D should redefine assignment to := then hopefully this type >>of bug will go away. (ie. we should learn from our mistakes) > >Like the authors of C, I find it most important to preserve a single >character operator for assignment. >I find := for assignment to be quite obnoxious. It's the worst choice >I've ever seen. Given the chance to redefine things, I would keep == for comparison exactly as it is. I would also keep = as it is *for the most common kind of comparsion* -- one where the result is not used. I would then introduce a new operator, perhaps :=, for the relatively rare assignment where the result is used. In other words, the type of an expression whose main operator is = is void. This lets us adopt a strict rule that not using an expression whose type is void is an error, without taking anything away from the programmer. (There is something to be said for dropping the := as defined above, so that instead of writing, for example, while ((ch = getchar()) != EOF) ... one would write while ((ch = getchar(), ch) != EOF) .... This gets a little uglier when the expression being assigned into is not a simple variable name, but still not so bad as all that. It will probably lead people to write x = 0; y = 0; instead of a single statement; but this strikes me as a minor point.) -- Frank Adams ihnp4!philabs!pwa-b!mmintl!franka Ashton-Tate 52 Oakland Ave North E. Hartford, CT 06108