[Issue 6434] opDispatch must be considered before alias this.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 16 02:39:09 PDT 2011


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


Max Samukha <samukha at voliacable.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |samukha at voliacable.com


--- Comment #2 from Max Samukha <samukha at voliacable.com> 2011-08-16 02:39:02 PDT ---
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.

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


More information about the Digitalmars-d-bugs mailing list