Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!caip!brl-adm!brl-smoke!rgh%inmet.uucp@BRL.Arpa From: rgh%inmet.uucp@BRL.Arpa Newsgroups: net.lang.c Subject: Re: What should be added to C Message-ID: <1249@brl-smoke.ARPA> Date: Tue, 10-Jun-86 16:30:29 EDT Article-I.D.: brl-smok.1249 Posted: Tue Jun 10 16:30:29 1986 Date-Received: Fri, 20-Jun-86 04:23:28 EDT Sender: news@brl-smoke.ARPA Lines: 41 GVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGV From: Frank Adams Subject: Re: What should be added to C To: info-c@BRL-SMOKE.ARPA Return-Path: Redistributed: Xerox-Info-C^.x@XEROX.ARPA Received: from BRL-AOS.ARPA by Xerox.COM ; 02 JUN 86 14:18:54 PDT Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015862; 2 Jun 86 17:05 EDT Received: from USENET by SMOKE.BRL.ARPA id a004718; 2 Jun 86 16:33 EDT Newsgroups: net.lang.c Message-ID: <1514@mmintl.UUCP> Posted: Fri May 30 07:58:19 1986 GVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGV 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