On Tue, May 22, 2007 at 01:25:33PM +0100, Nicholas Clark wrote: > > And how often does the type of a PMC change, such that its internal > data layout changes? In Perl 5 this morphing happens everywhere, > but in Parrot?
Actually, until/unless we have a "scalar container" or "reference" PMC of some sort, it appears to occur a lot. The example I keep coming back to is something like (Perl 6): my @a = (1, 2, 3); my $b := @a[2]; @a[2] = foo(); In PIR this becomes something like (simplified): ## my @a = (1, 2, 3); $P1 = '_buildlist'(1, 2, 3) # create a list .lex '@a', $P1 # bind as @a ## my $b := @a[2]; find_lex $P2, '@a' # look up @a set $P3, $P2[2] # get reference to @a[2] .lex '$b', $P3 # bind as $b ## @a[2] = foo(); $P4 = 'foo'() # $P4 could be any type find_lex $P5, '@a' # look up @a set $P6, $P5[2] # get reference to @a[2] assign $P6, $P4 # $P6 (Integer) has to morph # to whatever type $P4 is If we try to use a set opcode instead, as in: ## @a[2] = foo(); $P4 = 'foo'() # $P4 could be any type find_lex $P5, '@a' # look up @a set $P5[2], $P4 # set @a[2] to $P4 then we end up losing the binding between $b and @a[2] that was established earlier ($b still refers to the Integer). Pm