Nullable or Optional? Or something else?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Sep 2 14:30:22 PDT 2009


Danny Wilson wrote:
> Op Wed, 02 Sep 2009 22:55:53 +0200 schreef Andrei Alexandrescu 
> <SeeWebsiteForEmail at erdani.org>:
> 
>>>  So if pointers wouldn't be considered evil,  Maybe!T*  would suffice?
>>>  Can someone point me out what the big difference is between ref and 
>>> simply disallowing pointer arithmitic?  Is it marketing?
>>
>> Ref means lvalue of type T. Pointer is a type distinct from T. So 
>> although NullableRef!T is substitutable for an lvalue of type T, 
>> Nullable!(T*) is not.
>>
>>
>> Andrei
> 
> Thanks. I googled first but couldn't find some explicit documentation 
> about 'ref'  just it being mentioned here and there :-)
> 
> Are there any problems with something like:
> 
>  Nullable!(ref T)
> 
> ?

I'd love for that to work, but ref T is not a type. "ref" is a storage 
class that's allowed only in a function declaration context. (What "ref" 
means in that context is pass or return by reference as opposed to the 
default pass by value.)

Andrei



More information about the Digitalmars-d mailing list