Non-null objects, the Null Object pattern, and T.init

Yota yotaxp at thatGoogleMailThing.com
Fri Jan 17 09:52:18 PST 2014


On Friday, 17 January 2014 at 15:05:10 UTC, Michel Fortin wrote:
> On 2014-01-17 01:42:37 +0000, Andrei Alexandrescu 
> <SeeWebsiteForEmail at erdani.org> said:
>
>> Further avenues are opened by thinking what happens if e.g. 
>> init is private or @disable-d.
>> 
>> Thoughts?
>
> Some more thoughts.
>
> Couldn't we just add a class declaration attribute that'd say 
> that by default this type is not-null?

I have been hoping D would become not-null-by-default since I 
discovered the language.  Looking at what it has done with other 
type classes, (shared, immutable, etc) it always seemed like 
something that would be right up its alley.  However in my dream 
world, it would simply apply to all reference types by default.

I'm not a fan of using an attribute for this due to how hidden it 
is from the programmer.  You should be able to determine the 
nullability of something from looking at the code that uses it.  
But then again, I feel like there should also be a way to 
distinguish value types from reference types just by looking at 
the usage, so what do I know? =p


More information about the Digitalmars-d mailing list