develooper Front page | perl.perl6.internals | Postings from February 2002

PMCs, setting, and suchlike things

Thread Next
From:
Dan Sugalski
Date:
February 12, 2002 14:19
Subject:
PMCs, setting, and suchlike things
Message ID:
a0510140cb88f3035ee70@[63.120.19.221]
We've been going around a bit about how PMCs should be set and 
assigned to and suchlike things. So, here's the scoop.

There are three sorts of assignment:

1) Pointer assignment
2) Requests to get a value
3) Forced value sets

#1 is essentially a sort of bookkeeping. A pointer to one sort of PMC 
is replaced with another pointer. This happens, for example, with the 
SET opcode. It does *not* affect the contents of the destination PMC.

#2 is what you get with normal assignment. $foo = $bar, for example. 
$foo's assign vtable method is called with $bar as a parameter. $foo 
figures out what it should do--if it's a tied variable of some sort 
it should perform its assign action. (This includes throwing an 
exception if the assignment isn't valid) Otherwise it should 
typecheck the RHS and morph itself into the RHS's type.

#3 calls the destination PMC's destroy method if it has one. Then the 
source's clone method is called with the destination as the PMC 
passed in.

So, what about the ramifications of:

     $foo = @bar

@bar's get_integer method is called, and $foo's set_integer method is 
called. No temp PMCs.

     $foo = %bar

calls %bar's get_string method and $foo's set_string method.

     $foo = keys %bar (or whatever we're using in perl 6 for this)

calls %bar's get_integer method and $foo's set_integer method.

The only issue we really have is how do we get a scalar PMC for an 
aggregate PMC. Working on that.
-- 
                                         Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                       teddy bears get drunk

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About