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

Reply via email to