Hi,
Patrick R. Michaud wrote:
My first question is "How do I add a class method?" -- i.e.,
a method that operates on a class instance as opposed
to an object instance of that class. Ideally the answer
would contain explanations/examples for defining such
methods in PIR and also as PMC methods.
I had to deal with this when working on the .Net translator, though I
really fudged it. Basically, I just didn't have them as methods, but
rather subs. That meant they didn't expect an invocant. And I translated
the callmethod .Net op to do the Right Thing. Or something along those
lines. The disadvantage is that they won't dispatch as methods on the
instance of the object in Parrot-land (which is at least C#
behavior...you can't call static methods using obj.meth, only
class.meth, ignoring C# 3.0's extension methods). But that isn't Perl 6
behavior, as I understand it.
How about writing the method without the :method modifier, but also
addmethod'ing it to the class? Then it will be found by find_method, but
won't think the first parameter is an invocant. Something here doesn't
feel quite right to me, though I'm tired and can't put my finger on what.
Jonathan