Non-nullable references, again

Don nospam at nospam.com
Fri Jan 2 22:51:50 PST 2009


Michel Fortin wrote:
> On 2009-01-02 21:39:52 -0500, Benji Smith <dlanguage at benjismith.net> said:
> 
>> Think of it like this:
>>
>>    MyClass?.myProperty
>>
>> It's a static field of the nullable MyClass type.
> 
> Just like:
> 
>     MyStruct*.myProperty
> 
> It's a static field of the struct for which you have a pointer to. Exact 
> that for it to compile, you need to write:
> 
>     (MyStruct*).myProperty
> 
> I propose we do things the same way for "?".

That's encouraging. I wasn't able to find any other ambiguous situations 
(and the one I did find was very obscure); and it does seem (as you 
pointed out) that ambiguities with a*b are far more common.
It would be an awesome feature IMHO. Null class references are by far 
the most common bug I make in D. And despite what people have said, 
working out why a class is null is not always easy, especially when it 
only shows up rarely in production code.



More information about the Digitalmars-d mailing list