Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84; site opus.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!hao!nbires!opus!rcd From: rcd@opus.UUCP (Dick Dunn) Newsgroups: net.lang.c Subject: Poll on style issue in comparison Message-ID: <65@opus.UUCP> Date: Thu, 19-Sep-85 23:10:46 EDT Article-I.D.: opus.65 Posted: Thu Sep 19 23:10:46 1985 Date-Received: Sun, 22-Sep-85 06:37:42 EDT Distribution: net Organization: NBI,Inc, Boulder CO Lines: 38 I'd like to poll you folks on a small matter of style. I've seen it mentioned from time to time in lang.c. PLEASE email (DON'T POST) answers to the questions below; I'll post responses and comments in a bit. The issue is this: People tend to stumble over the difference between == and =. It's not that they don't know the difference; they just screw up, typically writing something like if (x=0) ... when they mean if (x==0) ... Some people have suggested reversing the order of comparisons, viz: if (0==x) ... so that the compiler will complain if = is substituted for ==. One argument against this form is that it is an unconventional order which is harder to read. - - - - - - - - - - - - - - - - - - - - - - - - - - The questions: 1. Do you use this form of comparison? 2. Regardless of whether you use it, how do you feel about it (e.g., other people using it in code that you will maintain)? - dislike it - neutral (OK if you want to do it) - like it 3. If you use or like this way of writing comparisons, how do you feel about also writing ordering tests with the constant first, as if (0