DMD can implicitly convert class pointer to the bool. Is it bug or terrible feature?

Dicebot public at dicebot.lv
Sun Nov 24 06:17:49 PST 2013


> So, pointer implicitly converts to false if pointer is null and 
> to true if pointer is not null. Is it bug or terrible feature? 
> Note that we have `f is null` syntax for these cases.

Not exactly. It is all about "if" condition. AFAIK, D defines 
that condition `if(X)` get re-written to `if(cast(bool)X)` before 
semantic pass. So it is kind of implicit explicit conversion :)


More information about the Digitalmars-d mailing list