On 03/13/2013 12:41 PM, deadalnix wrote:
On Tuesday, 12 March 2013 at 20:17:33 UTC, Ali Çehreli wrote:
...
So, apparently implicit conversion considers the class variable and
explicit conversion considers the class object. And this produces a
compilation error:

    B bnull;
    assert(cast(bool)bnull);

Error: null dereference in function _D6deneme19__unittestL123991_1FZv

Ali

bool toto = bfalse; // Error: cannot implicitly convert expression
(bfalse) of type module.B to bool

So it isn't the implicit cast kickin here, but a 3rd behavior. The kind
of behavior that makes D so special and create theses edges cases we all
love !

It's an unnecessary special case. assert(objRef); checks whether the object reference is not null and then it checks the object invariant. Walter thinks this is useful.

Reply via email to