Re: Paying developers to get features faster
From: Baho Utot (baho-utot_at_philippines-island.org)
Date: 01/25/04
- Next message: Baho Utot: "Re: Paying developers to get features faster"
- Previous message: Ford Prefect: "Re: free security help.."
- In reply to:(deleted message) Brad Olin: "Re: Paying developers to get features faster"
- Next in thread: Pascal Bourguignon: "Re: Paying developers to get features faster"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Sun, 25 Jan 2004 00:01:02 GMT
Brad Olin wrote:
> On Sat, 24 Jan 2004 01:56:45 GMT, Barry Margolin <barmar@alum.mit.edu>
> wrote:
>
>>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.
>
> Sorry for the slow reply...
>
> I agree, I didn't write the compiler, I just used it. The compiler I
> used was on the JPL campus and I can't really say much more than that.
>
> The one time that I have actually seen when the traditional "if (<var>)"
> test was an invalid test was a case of a pointer that should have been
> compared to NULL. i.e "if (<var> != NULL)" vrs "if (<var>)". I tracked
> this case down into a third party library that re-defined NULL to a
> non-zero value. I'm not a complete ANSI C guru, but I think that NULL
> is a notion of invalid and not guaranteed to be zero.
>
>
> Brad
That is why you shouldn't compare to NULL,
use for example if (char*) 0 != <var>).
Notice the constant is before the variable. This will generate a complier
complaint if you try if (0 = <var>) when you meant if ( 0 == <var>).
- Next message: Baho Utot: "Re: Paying developers to get features faster"
- Previous message: Ford Prefect: "Re: free security help.."
- In reply to:(deleted message) Brad Olin: "Re: Paying developers to get features faster"
- Next in thread: Pascal Bourguignon: "Re: Paying developers to get features faster"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|