Null references redux

Yigal Chripun yigal100 at gmail.com
Wed Sep 30 18:26:00 PDT 2009


On 30/09/2009 18:44, bearophile wrote:
> Max Samukha:
>
>> Don't get confused by 'new' in struct initializers. Structs in C# are
>> value types.
>
> Yes, you are right.
>
> But in D structs can be allocated on the heap too, so I think having optional nonnull struct pointers can be useful. The syntax and usage is similar to normal struct pointers.
>
> Bye,
> bearophile

why not just use references with structs?

struct S { ... }
S* sPtr = new S;
S sRef = *sPtr; // non-null ref

there is no need for non-null pointers.



More information about the Digitalmars-d mailing list