http://d.puremagic.com/issues/show_bug.cgi?id=6434



--- Comment #4 from Gor Gyolchanyan <g...@boloneum.com> 2011-08-16 03:55:33 PDT 
---
I agree. This would make more sense. Let the opDispatch be used after alias
this.

(In reply to comment #2)
> I am not sure. opDispatch is meant to be a fallback mechanism used after all
> regular lookups fail. For example, one intended use of opDispatch is to
> dynamically handle calls to members unavailable statically. With "alias this"
> given the lowest priority, one would need to manually forward calls to
> inherited members:
> 
> struct A
> {
>    Variant i;
>    alias i this;
> 
>    auto opDispatch(string name, A...)(auto ref A args)
>    {
>        static if (isCallableOnI!(name, A)))
>            mixin("return i." ~ name ~ "(args);"); // this shouldn't be
> necessary
>        else
>            return dispatchDynamically(name, toVariants(args));                
>  
>    }
> }
> 
> So the bug is in opDispatch not being considered after "alias this" lookup
> fails, and not in the order of lookups.

I think all VISIBLE members should be used before opDispatch.

(In reply to comment #3)
> On the other hand, opDispatch considered first gives much more flexibility.
> Then, what to do with regular inheritance:
> 
> class A
> { 
>     int foo();
> }
> 
> class B : A
> {
>    void opDispatch(string name)()
>    {
>    }
> }
> 
> auto b = new B;
> b.foo();
> 
> Should foo be opDispatched?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to