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. More specifically, PGE::Match is a subclass of Hash. It defines a method 'new' in the PGE::Match namespace, and then calls 'new' on the class object directly, as in compilers/pge/PGE/OPTable.pir [lines 289-290]:

 $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 get a signature mismatch error, because the 'new' method in Class only takes flat, named arguments, with no positional arguments.)

I can think of several ways to work with this. The simplest is to have PGE standardize on the new metamodel signature for 'new', passing the source string as an additional named argument, and returning a single instance object that contains pos, target, mfrom, and mpos. Any custom argument handling could be done by overriding init_pmc in PGE::Match.

The most complex would be to first subclass Class (as PGE::Class, or whatever), override the 'new' class method, and then create the PGE::Match class as an instance of PGE::Class. This would probably be too heavyweight performance-wise for PGE, and doesn't gain anything aside from keeping the signature on PGE::Match::new the same.

A few other options range between the two poles of complexity.

I'll leave this open for general comment, and especially for Patrick's thoughts, before I plumb it into the PDD 15 branch.

Allison

Reply via email to