null references redux + Looney Tunes

Jarrett Billingsley jarrett.billingsley at gmail.com
Sun Oct 4 15:15:17 PDT 2009


On Sun, Oct 4, 2009 at 5:58 PM, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> bearophile wrote:
>>
>> opIf sounds strange :-) Why don't you like the idea of the implicit
>> conversion to bool followed by the testing of the bool? (someone may
>> have already answered a similar question, please bear with me).
>
> Try this:
>
> void * p;
> if (p) {}
>
> Then try this:
>
> void * p;
> bool b = p;

Okay, how about if if() used the result of an *explicit* cast to bool?
Barring the silly opCast operator (and maybe providing something
else), would this be consistent?



More information about the Digitalmars-d mailing list