Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!pwa-b!mmintl!franka From: franka@mmintl.UUCP (Frank Adams) Newsgroups: net.lang.c Subject: Re: What should be added to C Message-ID: <1514@mmintl.UUCP> Date: Fri, 30-May-86 07:58:19 EDT Article-I.D.: mmintl.1514 Posted: Fri May 30 07:58:19 1986 Date-Received: Sun, 1-Jun-86 08:34:32 EDT References: <5498@alice.uUCp> <1462@mmintl.UUCP> <852@bentley.UUCP> Reply-To: franka@mmintl.UUCP (Frank Adams) Organization: Multimate International, E. Hartford, CT Lines: 27 In article <852@bentley.UUCP> kwh@bentley.UUCP writes: >>>o There should be an option to flag statements of the form if (v = e) ... >>>(Actually, I wouldn't be averse to a coding standard which forbade such >>>things, in favor of if (v = e, v) ...) > >Urgh. Are you talking about removing the assignment-has-a-value feature >completely, or a special case for "if (v = e)"? (I always write this as >"if ((v = e) != 0)" to make it clear that I didn't mean "if (v == e)".) > >Actually, the main argument in favor of valued assignment is to allow such >things as "while ((c = getchar()) != EOF)". This really doesn't look so >bad with the unvalued assignment "while (c = getchar(), c != EOF), so it >may not be such a bad idea. Actually, I was not proposing removing the assignment-has-a-value feature anywhere (although I would not put it into a new language I was designing). The proposal was that it be avoided in if's (and probably while's as well) as a coding standard. That is, it would be legal, but not recommended. In fact, I only use the results from an assignment in two cases. One is to assign the same value to multiple variables, and the other is in the if/while case under discussion here. (Yes, I also normally use "if ((v = e) != 0)"). I may stop using it in this latter case, in favor of the comma operator as described above. Frank Adams ihnp4!philabs!pwa-b!mmintl!franka Multimate International 52 Oakland Ave North E. Hartford, CT 06108