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

PDD15: newclass

0 views
Skip to first unread message

Jonathan Worthington

unread,
Apr 1, 2007, 7:46:27 PM4/1/07
to parrot-...@perl.org
Hi,

The PDD sayeth:

~~
newclass

$P1 = newclass $S2

Create a new base class named $S2, and put the PMC for it in $P1
~~

And elsewhere:

~~
When declaring a composed class, you can optionally supply an array of
method names that will be supplied by the class because of a conflict in
its roles. This is done using the named parameter resolve.
~~

I'm guessing that it is referring to declaring a new class with the
newclass op? If so, does newclass need to be a magic "op" that IMCC
actually translates to a set_args/get_results/newclass sequence, so you
can pass named arguments to the newclass op?

If yes, do we need that for add_role, add_method and add_attribute too,
since these can take named and optional parameters?

Thanks,

Jonathan

Allison Randal

unread,
Apr 1, 2007, 10:16:03 PM4/1/07
to Jonathan Worthington, parrot-...@perl.org
Jonathan Worthington wrote:
> Hi,
>
> The PDD sayeth:
>
> ~~
> newclass
>
> $P1 = newclass $S2
>
> Create a new base class named $S2, and put the PMC for it in $P1
> ~~
>
> And elsewhere:
>
> ~~
> When declaring a composed class, you can optionally supply an array of
> method names that will be supplied by the class because of a conflict in
> its roles. This is done using the named parameter resolve.
> ~~

Mmm... yes, the opcode does need another parameter. Added.

> I'm guessing that it is referring to declaring a new class with the
> newclass op? If so, does newclass need to be a magic "op" that IMCC
> actually translates to a set_args/get_results/newclass sequence, so you
> can pass named arguments to the newclass op?

The 'newclass' opcode itself will be just a simple opcode, so it can
only take fixed parameters. The newclass opcode is really just a
shortcut for C<new "Class"> as in:

$P0 = new "Hash"
$P0["name"] = "MyClassName"

$P1 = split " ", "foomethod barmethod bazmethod"
$P0["resolve"] = $P1

$P2 = new "Class", $P0

Or, alternately:

$P2 = new "Class"
$P2.name("MyClassName")

So, perhaps we need:

$P2.resolve($P1)

Or:

$P2.initialize("name" => "MyClassName", "resolve" => $P1)

> If yes, do we need that for add_role, add_method and add_attribute too,
> since these can take named and optional parameters?

The named parameters are only on the method calls, not the opcodes.

Allison

Jonathan Worthington

unread,
Apr 2, 2007, 7:02:31 PM4/2/07
to Allison Randal, parrot-...@perl.org
Allison Randal wrote:
> So, perhaps we need:
>
> $P2.resolve($P1)
Implemented this (both the interface and the semantics); test for it
added too.

Just got the changes to alias to handle, then hopefully role conflict
resolution is in sync with the PDD again.

Thanks for the clarifications,

Jonathan

0 new messages