Proposal : allocations made easier with non nullable types.
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Feb 10 06:11:06 PST 2009
Nick Sabalausky wrote:
> "Daniel Keep" <daniel.keep.lists at gmail.com> wrote in message
> news:gmpd71$8uj$1 at digitalmars.com...
>> Alex Burton wrote:
>>> I think it makes no sense to have nullable pointers in a high level
>>> language like D.
>> Oh, and how do you intend to make linked lists? Or trees? Or any
>> non-trivial data structure?
>>
>
> Null Object Pattern:
> --------------
> class LinkedListNode(T)
> {
> LinkedListNode!(T) next;
>
> private static LinkedListNode!(T) _end;
> static LinkedListNode!(T) end() {
> return _end;
> }
> static this() {
> _end = new LinkedListNode!(T);
> }
> }
> --------------
What is "next" for the _end node?
Andrei
More information about the Digitalmars-d
mailing list