Sam Ruby wrote:

Leopold Toetsch wrote:

The caller sets:

  mmd_flag := NULL     ... no MMD, plain method lookup
  mmd_flag := &depth   ... return the next matching method starting
                           at the given parent search depth

In the general case, how does the caller know that MMD is invoked?

Perl6 "multi sub"s are denoted with the "multi" keyword. We need some extensions to pdd03 that pass this information on to Parrot. It basically boils down to a new opcode:


  call_MMD "method", n

as described in subjects "MMD: more implications" and "MMD dispatch"

A cache invalidation function is called from add_method (and remove_method) which resets entries for the passed class.

And, in some languages, all calls to set_attr or setprop type methods, where the value invoked may be invokable, or might obscure visibility to one that is. As calls to setting attributes/properties are frequent, my concern is that this may more than wipe out any potential benefit that such a cache may provide.

You don't have operator overloading implemented in py*, do you? Anyway the code generator emits:


   add Px, Py, Pz

Now some attribute set operations on the class, metaclass or in the "__dict__" can mean an overloading of the "__add__" method of C<Py>. To handle that correctly, you can either not emit an "add" opcode in the first place, or you have to track the attribute set operations so that you are able to call the user-provided "__add__" method.
You can of course in the current scheme install an "add" MMD method that does always a full method lookup, but then you got the performance problem you are worrying about.


Also, note that the Perl sub defined above is not a method.

Yes. But Perl6 allows multi subs to be called as methods on the first invocant too:


  $a.foo($b, $c)   :=   foo($a, $b, $c)

Comments welcome,

Counter-proposal.

I see no reason why a full multi-dimensional multi-method dispatch PMC could not commence immediately, complete with a fully-functional polymorphic inline cache. Once it is ready and tested, we can explore setting things up so that the various mmd_dispatch_* functions to exploit this functionality for the existing predefined binary operations.

I don't see how this solves anything, except that you seem to be moving the burden of MMD to an additional PMC. What does this proposed MMD PMC do? How does it find the appropriate multi-method?


I've described a versatile MMD scheme that is able to do n-dimensional MMD. Counter-proposals are very welcome, but the proposal has to include the mechanism how it works. A "MMD PMC that does it" is too thin, sorry.

- Sam Ruby

leo



Reply via email to