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

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Jan 17 16:12:16 PST 2014


On 1/17/14 12:42 PM, Michel Fortin wrote:
> On 2014-01-17 20:21:36 +0000, Jacob Carlborg <doob at me.com> said:
>
>> On 2014-01-17 16:05, Michel Fortin wrote:
>>
>>> This is basically what everyone would wish for a not-null type to do.
>>> The syntax is clean and the control flow forces you to check for null
>>> before use. Misuses result in a compile-time error.
>>
>> Yes, exactly. But the issue is that the compiler needs to be modified
>> for this.
>
> Andrei's post was referring at language/compiler changes too: allowing
> init to be defined per-class, with a hint about disabling init. I took
> the hint that modifying the compiler to add support for non-null was in
> the cards and proposed something more useful and less clunky to use.

Yes, improving the language is in the cards. I have collected enough 
hard evidence to convince myself that null references are a real and 
important issue (previously I'd agreed with Walter who is considering it 
not particularly remarkable).

Andrei



More information about the Digitalmars-d mailing list