From: "Patrick R. Michaud" <[EMAIL PROTECTED]> Date: Wed, 20 Jun 2007 21:02:54 -0500
On Wed, Jun 20, 2007 at 09:41:00PM -0400, Bob Rogers wrote: > From: Jonathan Worthington <[EMAIL PROTECTED]> > Date: Thu, 21 Jun 2007 00:05:00 +0100 > > 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 . . . > > A method that operates on a class instance would be an instance method > of the class metaclass, wouldn't it? But I think you meant "on a > *particular* class [metaclass] instance", am I right? Yes, I believe this is a better phrasing. If I want to define a new method or or override an existing method on a metaclass instance [a class], then how do I do that? AFAICS, there isn't currently a good way to do that. (Depending, of course, on whether you think Jonathan's suggestion qualifies. ;-) Nor does PDD15 seem to cover this; it actually says very little about metaclasses, beyond just the fact that they exist (and even then only mentions class metaclasses). The particular instance I'm looking at is a C<Str> class for Perl 6, where I want the get_string vtable function for the C<Str> metaclass instance is different from get_string of a C<Str> class object. To me, the phrases "C<Str> metaclass instance" and "C<Str> class object" sound like the same thing. Did you mean "C<Str> object" in the second case? If so, then get_string on the class metaclass would just affect the way the class stringifies, and not any of the instances, but I don't get the point of that. So I'm sure I must be misunderstanding you. Do you have an example? Maybe the perl6 code you mention? -- Bob