From: [EMAIL PROTECTED] Date: Thu, 20 Dec 2007 00:53:12 -0800 (PST) Author: allison Date: Thu Dec 20 00:53:11 2007 New Revision: 24108
Added: trunk/docs/pdds/pdd27_multiple_dispatch.pod . . . [pdd] Launch the Multiple Dispatch PDD. I notice that this doesn't allow for anonymous classes, since provision is made only for named classes. Is anonymous class support in prospect? (The PDD does mention C<push_pmc> as the PIR API for adding methods to multisubs, but such a sub must have already been declared :multi, with named classes, so the C<push_pmc> will have been done automatically anyway by the loader.) To define a methods that dispatch on anonymous classes, one would need to be able to pass an ordinary (non-:multi) sub and an array of class objects to the method-adding method. Since it is syntactically illegal to put ":invocant" on non-multi subs, either this restriction would have to be lifted, or some other means of declaring invocant args would be needed, perhaps using a distinguished non-class value in the class list. BTW, shouldn't there be a requirement that the number of classes in the :multi attribute match the number of :invocant params? If not, what does this mean? As Klaas-Jan pointed out, the magical "_" is not documented. But I think we need a better way to specify "any type". First of all, there is no way to say "any PMC type" as distinguished from "any register type" and "any type at all" (I think "_" means the last alternative, true?). Secondly, these types need explicit class names that point to explicit class objects, at which point special-casing for "_" (among other things) becomes unnecessary. And somewhere, maybe not here, the type network of all Parrot built-ins needs to be specified. This amounts to casting it in stone, but if we don't do it explicitly, it will be effectively cast in stone by virtue of all the code that will break if we try to change it. Finally, a question: What is the difference between an :invocant parameter that isn't specialized (i.e. specifies "_" as the :multi dispatch class), and leaving that parameter out of the :multi list altogether? In other words, is there any practical difference between this: .sub test1 :multi(Integer, _, Integer) .param pmc i1 :invocant .param pmc x2 :invocant .param pmc i3 :invocant . . . .end and this: .sub test1 :multi(Integer, Integer) .param pmc i1 :invocant .param pmc x2 .param pmc i3 :invocant . . . .end ? TIA, -- Bob Rogers http://rgrjr.dyndns.org/