Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!lll-lcc!styx!twg-ap!amdahl!pyramid!ucat!pesnta!wjvax!brett From: brett@wjvax.UUCP (Brett Galloway) Newsgroups: net.lang.c Subject: Re: Equality vs Assignment Message-ID: <758@wjvax.wjvax.UUCP> Date: Thu, 25-Sep-86 12:55:59 EDT Article-I.D.: wjvax.758 Posted: Thu Sep 25 12:55:59 1986 Date-Received: Fri, 26-Sep-86 21:06:30 EDT References: <2259@gitpyr.UUCP> <270@myrias.UUCP> Reply-To: brett@wjvax.UUCP (Brett Galloway) Organization: Watkins-Johnson Co., San Jose, Calif. Lines: 30 Keywords: Who has not been bitten In article <270@myrias.UUCP> cg@myrias.UUCP (Chris Gray) writes: >The proper place for this check is of course as a warning issued by the C >compiler. It's not all that hard - it took me about 30 lines of code in the >compiler (ANSI draft based) that I've done. It's a check I felt was quite >important, since I've been bitten by it too many times (I program in other >languages besides C, where '=' IS a comparison). I disagree; the proper place for this check is NOT as a warning issued by the compiler. "if(var=value)" is a perfectly valid, supported, and documented construction, endorsed by K & R et al. The fact that it is misleading is an artifact of the ambiguity of the meaning of "equal" and "=". In any event, it is a well-defined and supported feature of the language. It is ridiculous for the compiler to bark on the expression (var=value) when it happens to fall into the context of a simple if(). The proper place for this check is within lint, whose purpose is to ... detect features of ... [C programs] ... which are likely to be bugs, or non-portable, or wasteful. - lint(1), from 4.2 BSD manual Further, it should be a special test by lint, invoked by a special argument, so that those of us who like to use lint don't have to listen to the warning forever. -- ------------- Brett Galloway {pesnta,twg,ios,qubix,turtlevax,tymix,vecpyr,certes,isi}!wjvax!brett