Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MakeObject - an Object Instantiation Experiment

5 views
Skip to first unread message

Chromatic

unread,
Oct 10, 2006, 2:41:08 PM10/10/06
to parrot-...@perl.org
Hi all,

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

make_object.patch

Chromatic

unread,
Oct 10, 2006, 3:32:21 PM10/10/06
to perl6-i...@perl.org, Leopold Toetsch
On Tuesday 10 October 2006 12:23, Leopold Toetsch wrote:

> 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

Leopold Toetsch

unread,
Oct 10, 2006, 3:23:10 PM10/10/06
to perl6-i...@perl.org
Am Dienstag, 10. Oktober 2006 20:41 schrieb chromatic:
> Hi all,
>
> Here's an experiment I worked on yesterday to make creating objects a
> little easier from PIR.

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

Leopold Toetsch

unread,
Oct 10, 2006, 4:31:28 PM10/10/06
to perl6-i...@perl.org
Am Dienstag, 10. Oktober 2006 21:32 schrieb chromatic:
> >   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.

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

0 new messages