Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site udenva.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!hao!nbires!boulder!cisden!udenva!lspirkov From: lspirkov@udenva.UUCP (Goldilocks) Newsgroups: net.lang.c Subject: Re: condition convention 'if (10 == j)...' Message-ID: <573@udenva.UUCP> Date: Mon, 29-Apr-85 13:00:27 EDT Article-I.D.: udenva.573 Posted: Mon Apr 29 13:00:27 1985 Date-Received: Thu, 2-May-85 00:52:35 EDT References: <137@bocklin.UUCP> <> Reply-To: lspirkov@udenva.UUCP (Goldilocks) Organization: U of Denver Lines: 28 In article <> gam@amdahl.UUCP (G A Moffett) writes: >> 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. > >I think this is a good idea. Any criticisms? The only problem >I have with it is that I am not accustomed to reading code written >this way. >-- >Gordon A. Moffett yeah, it does seem very odd to ask if 10 equals something else. after all, 10 == 10 and nothing else. j is the variable. it's easy to think the other way around. i have a friend that uses macros to avoid the silly mistake. instead of saying if (j == 10) he defines a macro IS and says if (j IS 10). -- Goldi email: udenva!lspirkov