Here's an experiment I worked on yesterday to make creating objects a little
easier from PIR. The MakeObject library allows you to create an object by
passing its name (or, more usefully, a Key PMC) and a set of named arguments
to the initializer.
It then calls the class's BUILDALL() method, if it exists, or the BUILD()
methods on each class, least-to-most-derived, passing the arguments.
This surprisingly removes a lot of complexity in PIR objects.
-- c
> PPS: new opcode variant count is 20 now.
>
> I can imagine that we just have these:
>
> new P0, .Class # plain form
> new P0, .Class, <args>
> new P0, [class], <args>
Is <args> a PMC (Hash) or a list of named arguments? Creating a Hash for
every initializer is a real bummer in PIR.
(It makes me want to suggest that, just as [ class ] creates a Key PMC behind
the scenes, so { key => value } creates a Hash PMC.)
-- c
For reference:
Subject: PMC and object creation
http://groups.google.de/group/perl.perl6.internals/browse_frm/thread/e68dc0a0a96585b7/462023a5939b0844?lnk=st&q=toetsch++new+opcodes&rnum=30#462023a5939b0844
PS: the examples are w/o syntactic sugar support for making the
'new/instantiate' thingy any nicer. It's just an experiment how it could
work. The basics are: it combines all the flexible argument passing features
we already have with object instantiation.
PPS: new opcode variant count is 20 now.
I can imagine that we just have these:
new P0, .Class # plain form
new P0, .Class, <args>
new P0, [class], <args>
leo
As said, <args> ought to be everything conforming to current calling
conventions.
o = new .TypeId, 1, 'baz', 'x' => 'foo', 'y' => 42
or whatever - that's the plan(tm).
leo