Path: utzoo!utgpu!water!watmath!clyde!cbosgd!osu-cis!tut!lvc From: lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) Newsgroups: comp.lang.c Subject: Re: (So-called) ANSI C Message-ID: <4160@tut.cis.ohio-state.edu> Date: 10 Jan 88 14:29:00 GMT References: <4668@pyr.gatech.EDU> <495@xyzzy.UUCP> <9930@mimsy.UUCP> <6996@brl-smoke.ARPA> <10027@ut-sally.UUCP> <1821@bsu-cs.UUCP> Organization: The Ohio State University Dept of Computer and Information Science Lines: 33 Rahul Dhesi writes: ... >MSDOS :-), but I seem to recall that while Turbo C will complain about > > if (a = getinput()) > >(and I think it ought to), it will not complain about the equivalent > > if ((a = getinput()) != 0) > >since you are making your intention clear, both to the human reader and >to the compiler. I think Datalight C makes the same distinction. >-- >Rahul Dhesi UUCP: !{iuvax,pur-ee,uunet}!bsu-cs!dhesi Does it also restrict assignment in whiles and the test part of a for loop? What about: if ((a = getinput())) I disagree very strongly. This should not be restricted by the *compiler*. This is a perfectly legitimate thing to do, you just have to be careful. Use a separate program (or compile time option) to *check* for this. There is the public domain ccheck and a syntax checker (inspect) that I wrote (you'll have to buy it from AT&T through the Toolchest) that will flag this (among other things). Maybe X3J11 should have a representative from OSHA to make certain the users of ANSI C don't hurt themselves stupidly! -- Larry Cipriani AT&T Network Systems at cbosgd!osu-cis!tut!lvc Ohio State University