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

Peter Alexander peter.alexander.au at gmail.com
Thu Jan 16 18:13:33 PST 2014


On Friday, 17 January 2014 at 02:08:07 UTC, Andrei Alexandrescu 
wrote:
>>> assert(x == 42 && parent is Widget.init);
>>
>> Is that meant to say "x is Widget.init"?
>
> To clarify:
>
> assert(Widget.init.x == 42 && Widget.init.parent is 
> Widget.init);

Ah right, missed the parent parameter... Also ignore my previous 
comment in that case :-)

However, I'm not sure this is good. Those kinds of reference 
cycles can easily lead to infinite loops. Is that really an 
improvement on a null-pointer dereference?


More information about the Digitalmars-d mailing list