On Mon, Sep 17, 2007 at 03:38:58PM -0700, Allison Randal wrote: > PGE relies on an assumption of the old object metamodel that's no longer > valid: that defining a method in the namespace of the class will allow > you to call it as a class method. > [...] > $P0 = getclass 'PGE::Match' > (mob, pos, target, mfrom, mpos) = $P0.'new'(mob, adverbs :flat :named) > > Under the new metamodel, this doesn't work, because instance methods and > class methods are sharply distinguished. > [...] > I can think of several ways to work with this.
The one I'm likely to want to go with is to follow Perl 6's model, which is that 'new' will be a method on a PGE::Match proto-object. Indeed, I think that PGE also relies on Match objects themselves being able to respond to 'new'. So, the model I'd expect to ultimately aim for is something like: $P0 = get_hll_global [ 'PGE' ], 'Match' (mob, pos, target, mfrom, pos) = $P0.'new'(mob, adverbs :flat :named) In this example it doesn't matter if $P0 is the actual class object -- it can just be an instance of PGE::Match that knows how to deal with the 'new' method (either because it's a method in the class or because it's specifically composed into the protoobject). Most of the compiler tools are being created based upon this model of object creation -- i.e., there's a proto-object somewhere that is accessed via normal symbol table lookups, and a 'new' method on that object is used to create an instance of the class. I can go ahead and switch PGE to use a model like this in the trunk branch if that would help. Note that PGE also uses a similar 'newfrom' method that has been left in for compatibility with older versions of PGE -- eventually those should also be converted into calls to 'new'. Hope this helps, Pm