Developing a plan for D2.0: Getting everything on the table

bearophile bearophileHUGS at lycos.com
Wed Jul 15 14:37:06 PDT 2009


Daniel Keep:
> Because:
> 
> > struct NonNullable(T)
> > {
> >   T ptr;
> >   alias ptr this;
> >
> >   this(T ptr)
> >   {
> >     assert(ptr !is null);
> >     this.ptr = ptr;
> >   }
> >   this(NonNullable!T ptr)
> >   {
> >     this.ptr = ptr.ptr;
> >   }
> > }
> >
> > // Boom!  I just broke your non-nullable type!
> > NonNullable!Object o;

I am sorry, but I don't understand still. That's valid D2 code, and I can understand it. But from its look it seems (beside the not handy syntax, it's not as adding a "?") the opposite of what I was saying (that by default all D objects have to be non-nullable). Can you please help me understand? :-)

Bye,
bearophile



More information about the Digitalmars-d mailing list