Re: Paying developers to get features faster

From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 01/24/04


Date: Sat, 24 Jan 2004 01:56:45 GMT

In article <k33310hjf6f2j8k3qmbtfsvg242tps7cm2@4ax.com>,
 Brad Olin <bwo@bwo1.com> wrote:

> >I might be thinking silly here but why not write
> >
> ><var> = <expression>;
> >if (<var>) ....
> >
>
> Actually, it should have been coded as...
>
> if ((<var> = <exp>) != 0)
>
> and your solution should be coded as...
>
> <var> = <exp>;
> if (<var> != 0)
>
> The ANSI C language assumes a non-zero compare by default. All you are
> trying to do here is to remove the assumption and confirm your compare
> statement. There are strict C compilers (not gcc) that would complain
> about your solution. They are a pain in the but to work with, but
> probably worth it in the long run.

Why? The style:

if (<var>) ...

is *extremely* common. Any compiler that warns about it will produce
volumes of warnings for thousands of perfectly fine programs. Any C
programmer who considers this poor style is way out of the mainstream.
I can't imagine these C compilers being very popular.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


Relevant Pages

  • Re: Paying developers to get features faster
    ... > The ANSI C language assumes a non-zero compare by default. ... programmer who considers this poor style is way out of the mainstream. ... I can't imagine these C compilers being very popular. ...
    (comp.os.linux.security)
  • Re: Paying developers to get features faster
    ... > The ANSI C language assumes a non-zero compare by default. ... programmer who considers this poor style is way out of the mainstream. ... I can't imagine these C compilers being very popular. ...
    (comp.os.linux.development.system)
  • Re: Paying developers to get features faster
    ... > The ANSI C language assumes a non-zero compare by default. ... programmer who considers this poor style is way out of the mainstream. ... I can't imagine these C compilers being very popular. ...
    (comp.security.misc)
  • Re: When did K&R function declarations become obsolete?
    ... compilers I used by the early 80s offered vendor specific ... any official 'ANSI' yet. ... today's environment where the usual process is to develop a "standard" ... business requirement that it compile and run on multiple OS's. ...
    (comp.lang.c)
  • Re: When did K&R function declarations become obsolete?
    ... compilers I used by the early 80s offered vendor specific ... any official 'ANSI' yet. ... that existing investment in pre-ANSI code couldn't be ... declared with different prototypes on different systems. ...
    (comp.lang.c)