Adding the ?. null verification

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 19 10:37:02 PDT 2014


On Thu, Jun 19, 2014 at 05:26:31PM +0000, Tofu Ninja via Digitalmars-d wrote:
> On Thursday, 19 June 2014 at 16:58:03 UTC, Yota wrote:
> >Won't opDispatch here destroy any hope for statement completion in
> >the future?  I feel like D already has little hope for such tooling
> >features, but this puts the final nail in the coffin.
> 
> Yeah.... D is already really bad for auto completion, opDispatch just
> makes it harder. If we ever get to the point where the compiler is
> usable in a library form, that might pave the way to much better auto
> complete, but it looks far off.

In this case, the signature constraint on opDispatch could be used for
auto completion:

            auto opDispatch(string field)()
                if (is(typeof(__traits(getMember, t, field))))
		...

>From the signature constraint, it should be obvious that "field" must be
among the members of t.

Of course, checking signature constraints isn't always practical in the
general case where it may be arbitrarily complex, but obvious cases like
this one should be easily manageable, no?


T

-- 
Let's not fight disease by killing the patient. -- Sean 'Shaleh' Perry


More information about the Digitalmars-d mailing list