Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 alpha 4/15/85; site elsie.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!elsie!ado From: ado@elsie.UUCP (Arthur David Olson) Newsgroups: net.lang.c Subject: Re: condition convention 'if (10 == j)...' :-) Message-ID: <5115@elsie.UUCP> Date: Tue, 7-May-85 13:15:46 EDT Article-I.D.: elsie.5115 Posted: Tue May 7 13:15:46 1985 Date-Received: Thu, 9-May-85 01:44:01 EDT References: <137@bocklin.UUCP> <1456@amdahl.UUCP> <2140@sun.uucp> Organization: NIH-LEC, Bethesda, MD Lines: 17 Summary: (10 == j) takes longer to compile than (j == 10) > To prevent silly mistakes like > if (j = 10) > I usually write > if (10 == j) > By putting the constant first, I ensure that the compiler will catch the > typo. Do remember, however, this quote from "A Tour Through the Portable C Compiler": ". . .in cases where a relational operation is being done, and one operand is a constant, the operands are permuted, and the operator altered, if necessary, to put the constant on the right." This means that it will take longer to compile expressions of the form "(10 == j)" than it will to compile expressions of the form "(j == 10)". :-) -- UUCP: ..decvax!seismo!elsie!ado ARPA: elsie!ado@seismo.ARPA DEC, VAX and Elsie are Digital Equipment and Borden trademarks