NaNs Just Don't Get No Respect

Walter Bright newshound2 at digitalmars.com
Sun Aug 19 15:07:52 PDT 2012


On 8/19/2012 2:41 PM, Simen Kjaeraas wrote:
> Nullable!int a;
>
> int x = a; // Compile-time error: a might be null!
>
> if ( a ) {
>     int y = a; // 's fine, we know it's not null.
> }

You'd want the int to be the non-nullable type. You can do this with D's type 
system. Each state would be a different type, with user defined conversions 
between them.




More information about the Digitalmars-d-announce mailing list