January 03, 2009 Re: Non-nullable references, again | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | On 2009-01-02 20:44:21 -0500, "Jarrett Billingsley" <jarrett.billingsley@gmail.com> said: > On Fri, Jan 2, 2009 at 8:35 PM, Michel Fortin <michel.fortin@michelf.com> wrote: >> >> How's this different from >> >> case a*.b: >> >> is this: >> >> case ((a*).b): >> >> or is it: >> >> case ((a) * (.b)): > > What the heck is ((a*).b)? * is not a postfix operator. It is, kind of: if "a" is a type, postfix "*" makes it a pointer. If you test it, it'll compile if "a" is a struct having a member "b". -- Michel Fortin michel.fortin@michelf.com http://michelf.com/ | |||
January 03, 2009 Re: Non-nullable references, again | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Michel Fortin | Michel Fortin wrote:
> On 2009-01-02 21:39:52 -0500, Benji Smith <dlanguage@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.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply