DIP66 1.2 (Multiple) alias this. Continuation of work.

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 31 23:35:11 PDT 2015


On 2015-03-31 22:01, Andrei Alexandrescu wrote:

> I made a few editorial passes, no major changes. I think there's still a
> fly in the ointment. The resolution algorithm goes:
>
> 1. If xyz is a symbol (member, method, enum etc) defined inside
> typeof(obj) then lookup is done.
> 2. Otherwise, if xyz is a symbol introduced in the base class (where
> applicable), then lookup is done.
> 3. Otherwise, if opDispatch!"xyz" exists, then lookup is done.
> 4. Otherwise, alias this is attempted transitively, and if xyz is found,
> then lookup is done.
> 5. Otherwise an UFCS rewrite is effected.
>
> This puts opDispatch in between inheritance and subtyping, which I think
> we discussed is inappropriate - alias this should be effectively subtyping.
>
> If we're really convinced alias this means multiple subtyping, the
> inherited type should not have a special role. However, it simplifies a
> lot of things to give one particular subtype a leg up on all others. So
> I think this would work:
>
> 1. If xyz is a symbol (member, method, enum etc) defined inside
> typeof(obj) then lookup is done.
> 2. Otherwise, if xyz is a symbol introduced in the base class (where
> applicable), then lookup is done.
> 3. Otherwise, if xyz is found at least via either an opDispatch!"xyz" or
> alias this conversion, then lookup is done.
> 4. Otherwise an UFCS rewrite is effected.

Should opDispatch or "alias this" ever be looked up in the base class?

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list