Paul Hsieh wrote:
> On May 6, 11:47 am, Tomás Ó hÉilidhe <t...@lavabit.com> wrote:
>> On May 6, 7:19 pm, Keith Thompson <ks...@mib.org> wrote:
>>
>>> Such a warning seems perfectly friendly to me. Would you prefer that
>>> it didn't tell you that you might have mistyped "==" as "="?
>> I love what gcc has to say about it:
>>
>> warning: suggest parentheses around assignment used as truth value
>>
>> I've actually taken its advice and started doing:
>>
>> if ((i=5)) DoWhatever();
>
> Whenever I do that I usually write it as:
>
> if (0 != (i = 5)) DoWhatever();
>
> to make it absolutely crystal clear what I mean.
Wouldn't
i = 5;
DoWhatever();
be even more crystalline? Maybe a more believable example
might :
while (p = p->next) ...
vs.
while ( (p = p->next) ) ...
vs.
while ( (p = p->next) != NULL ) ...
--
Eric.Sosman@sun.com