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

[NEW] library/objecthacks.imc

5 views
Skip to first unread message

Jens Rieks

unread,
Mar 9, 2004, 1:34:50 PM3/9/04
to perl6-i...@perl.org
Hi all,

The attached file has some helper functions to make object usage easier.
It is used by the new object orientated Data::Dumper implementation as well as
my EBNF parser generator.
I submit it as a standalone library to reduce code duplication. It might also
be useful for other developers too.
Please refer to the POD of this library for more information about it.

jens

objecthacks.imc

Jens Rieks

unread,
Mar 10, 2004, 5:26:43 AM3/10/04
to perl6-i...@perl.org, Leopold Toetsch
Hi,

On Tuesday 09 March 2004 21:17, Leopold Toetsch wrote:

> Good. I've seen these functions :) They are fine, except for one:
> >=item (retvals) = __call( obj, methodname, ... )
> >
> > set S0, S5
> > set P2, P5
>
> [ snipped a lot more reg moves ]
>
> This isn't really looking good.
>
> what about:
>
> (retvals) = obj.methodname(...)
Yes that would be the best solution. I had a cursory look at the IMCC sources,
but found no obvious way to implement it.

> Melvin would that be ok? It *should* be a simple extension of the
> current function call syntax. We need to emit above two lines
> additionally and C<callmethcc> instead of C<invokecc>, that's all,
> AFAIK.

Is there a way to get the parent (one should be enough for now) of a
ParrotClass? I attached the parent ParrotClass as a property in __new_class,
but that does not work anymore because its now possible to use the function
with the name of the class to subclass from.
Is it possible to get a ParrotClass if the name is known, without having to
instantiate an object of that type and using the getclass op on it?
If I know how to do that I can add a "__multicall" function that calls the
specified method on all base classes, starting with the root baseclass. It is
usefull for constructor calling, to make sure that all base classes are
initialized in the proper order.

> leo
jens

Leopold Toetsch

unread,
Mar 10, 2004, 6:08:24 AM3/10/04
to Jens Rieks, perl6-i...@perl.org
Jens Rieks <par...@jensbeimsurfen.de> wrote:
> Hi,

> On Tuesday 09 March 2004 21:17, Leopold Toetsch wrote:
>>
>> what about:
>>
>> (retvals) = obj.methodname(...)

> Yes that would be the best solution. I had a cursory look at the IMCC
> sources, but found no obvious way to implement it.

I'll have a look at it.

> Is there a way to get the parent (one should be enough for now) of a
> ParrotClass?

No. And what about multiple parents? For SI it's simple. But we could
return the immediate parent in seach order.

> Is it possible to get a ParrotClass if the name is known, without having to
> instantiate an object of that type and using the getclass op on it?

The C<getclass> opcode does return the class PMC.

> If I know how to do that I can add a "__multicall" function that calls
> the specified method on all base classes, starting with the root
> baseclass. It is usefull for constructor calling, to make sure that
> all base classes are initialized in the proper order.

This should be done inside objects.c.

> jens

leo

Leopold Toetsch

unread,
Mar 10, 2004, 6:54:08 AM3/10/04
to Jens Rieks, perl6-i...@perl.org
Jens Rieks <par...@jensbeimsurfen.de> wrote:

> ... It is usefull for constructor calling, to make sure that


> all base classes are initialized in the proper order.

I've checked in a small change to objects. __init get's now called on
all parent classes in reverse search order. Then __init on the class
is called.

> jens

leo

Jens Rieks

unread,
Mar 10, 2004, 7:44:50 AM3/10/04
to l...@toetsch.at, perl6-i...@perl.org
Hi,

Works great, thank you!
I'll write a test for it later today.

> > jens
>
> leo
jens

0 new messages