Disallow null references in safe code?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Feb 4 10:41:21 PST 2014


On 2/4/14, 6:54 AM, Adam D. Ruppe wrote:
> On Tuesday, 4 February 2014 at 14:34:49 UTC, Idan Arye wrote:
>> Probably because `Nullable!` suggests that's it's a library solution -
>> and it isn't.
>
> It should be. The way I'd do it is
>
> Object o; // not null
> @nullable Object o; // like we have today
>
> BUT, user code would never use that. Instead, we'd have:
>
> struct Nullable(T) if(__traits(compiles, (@nullable T) {}) {
>     @nullable T;
> }

Yah, that's what I have in mind.

Andrei



More information about the Digitalmars-d mailing list