DMD 1.019 and 2.003 releases
BCS
ao at pathlink.com
Tue Jul 24 15:32:58 PDT 2007
Reply to 0ffh,
> BCS wrote:
>
>> Reply to 0ffh,
>>
>>> If I know that testing a condition is nothing but comparing a number
>>> to zero, writing "if (number!=0)" just becomes redundant.
>>>
>> actually ASM usually has built in >, < and = comparisons, some times
>> these implicitly use 0 for the other side, but it still it is not
>> /just/ a zero test.
>>
> Forgive me if I am being thick, but given C (or even D), when does
> "if (x!=0)" (or "if (x!=null)") ever give a different result from "if
> (x)"?
Never to my understanding. However this is a good reason to do the more verbose
one in that the compiler gets more info and then can use that for optimization
(maybe). That however is more of a general rule rather than just for this
case.
More information about the Digitalmars-d-announce
mailing list