From: Leopold Toetsch <[EMAIL PROTECTED]> Date: Fri, 24 Mar 2006 19:29:47 +0100
On Mar 24, 2006, at 18:38, Chip Salzenberg wrote: > On Fri, Mar 24, 2006 at 04:23:53PM +0100, Leopold Toetsch wrote: > . . . >> cl = getclass 'MyClass' >> o = __instantiate(cl, p0, p1, 'extra' => p2) > > Why not use the existing method call technique for this, and simply > standardize on a method name? A method call requires a PMC . . . Or a class, or proxy therefor. __instantiate can dispatch on a class, figure out how to construct a raw PMC, and pass the initializers to a new __initialize_instance method to fill in the slots. The __instantiate methods for String and Integer can look up the relevant class. Of course, that requires two dispatches instead of one, and wouldn't be as fast as separate opcodes . . . Above scheme (a function call with standardized name) also works with class integer IDs (and class name strings, when implemented). It saves plenty of time on the class lookup, when called with integer IDs. Couldn't this also be done as a PIR-level optimization? I.e. emit a different instruction if the first arg is an I reg? The C<set_args> / C<instantiate> opcodes could of course be united to a more general C<new> opcode, that takes a variable amount of initializers. And one standardized scheme of object creation is of course much faster than all the current workarounds. leo Sounds great to me. -- Bob Rogers http://rgrjr.dyndns.org/