Mea Culpa

Ary Borenszweig ary at esperanto.org.ar
Wed Mar 5 02:33:16 PST 2008


Thanks!

I wanted to implement that functionality by adding it to the port in 
Descent, but I reverted because then some errors appeared in phobos, and 
I thought I got the logic wrong. Maybe those errors were legitimate 
after all... :)

Walter Bright escribió:
> I know that many of you have asked that the compiler diagnose an error for:
> 
>    Class C { }
>    C c;
>    if (c != null)
>        ...
> 
> because it will seg fault at runtime (depending on how opEqual() was 
> written). I resisted because there is no way, in the general case, to 
> detect at compile time if one of the operands will evaluate to null or 
> not. But I finally thought "most of the cases, null is used directly", 
> so I put in a test in the compiler which rejects class == and != with 
> the literal null.
> 
> I found some errors in my own D code with it.
> 
> You guys were right.
> 
> The compiler will now also reject things like:
> 
>     if (c > null)
> 
> which make no sense.



More information about the Digitalmars-d mailing list