Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site decwrl.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!harvard!think!mit-eddie!genrad!decvax!decwrl!dec-rhea!dec-ultra!herbison From: herbison@ultra.DEC (B.J.) Newsgroups: net.lang.c Subject: Re: condition convention 'if (10 == j)...' Message-ID: <1879@decwrl.UUCP> Date: Sun, 28-Apr-85 13:22:24 EDT Article-I.D.: decwrl.1879 Posted: Sun Apr 28 13:22:24 1985 Date-Received: Tue, 30-Apr-85 02:38:47 EDT Sender: daemon@decwrl.UUCP Organization: DEC Engineering Network Lines: 37 > What do you mean, any criticisms? This is one of the most ugly > perversions of C I've ever seen! I tend to read this in terms of > "if variable equals constant" and try to figure out how the value > "10" is ever going to change! YUCK YUCK YUCK!!!! > > People that write "if (10 == j)" probably also write "while (1)". > What do you mean, "while 1"??? Are you expecting "1" to change??? > Everyone knows this should be written "for (;;)", read "forever". > > Bill Shannon I am glad that this discussion has been kept civil and that you restrained from using emotional or personal attacks. We wouldn't want net.lang.c to be confused with net.flame or net.abortion. Tell me Bill, is that how you respond whenever someone makes a comment you don't agree with -- yelling "YUCK YUCK YUCK" in their face? I'm glad I don't work with you. Personally, I don't like "while (1)", I much prefer "while (TRUE)", just so it is obvious what is going on. A much better solution, which explicitly says what is happening, is #define loop_forever But back to the original topic. "one of most ugly perversions of C"-- I tend to only use language this strong for things like the fact that "=" is the assignment operator in C rather than a test for equality. I am used to it, but it was a bad mistake and has cost thousands of people tens of thousands of wasted hours in looking for the bugs it has caused. Using 'if (CONSTANT == j)...' [avoid putting magic numbers in code, that can cause bugs also] seems like a way to help solve problems. In the meantime, try to avoid using code like 'if ((i+1) == (2*j))...', some people (by their own admission) might not be able to handle a comparison where neither side is a variable and neither side is a constant. B.J. Herbison%Ultra.DEC@decwrl.ARPA