Smart pointers instead of GC?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Feb 2 13:16:50 PST 2014


On 2/2/14, 11:58 AM, Walter Bright wrote:
> On 2/2/2014 8:55 AM, Andrei Alexandrescu wrote:
>> 1. Add @nullable and provide a -nullable compiler flag to verify it. The
>> attribute is inferred locally and for white-box functions (lambdas,
>> templates),
>> and required as annotation otherwise. References not annotated with
>> @nullable
>> are statically enforced to never be null.
>
> I want to clarify that @nullable would be a storage class, NOT a type
> constructor. This means it will apply to the variable itself, not its type.
>
> For example:
>
> @nullable T* p;
> auto q = p;      // q is a T*, not @nullable
>
> In a way, it would work much like ref, which is also a storage class and
> not a type constructor.

That creates problems with creating arrays of nullable objects, as Timon 
Gehr mentioned.

We need to think this through.

Andrei




More information about the Digitalmars-d mailing list