Gordon Henriksen wrote:
(PMCs have reference semantics[1])
Isn't that the job of Perl's \ operator?
Did you read on to [1] too?
I read
[1] new P1, .PerlHash new P3, .PerlString set P3, "yyy\n" set P1["a"], P3 set P0, P1["a"] print P0 set P0, "xxx\n" set P2, P1["a"] print P2 end yyy xxx
as equivalent to...
$hash{a} = "yyy\n"; $y := $hash{a}; # Note :=lhs instead of =lhs or =\lhs. print $y; # yyy $y = "xxx\n"; print $hash{a}; # xxx
Makes sense.
My point was only that element lookup in an rvalue (get) should be explicitly non-modifying—only element lookup in an lvalue context (put) should auto-vivify. But indirect puts like this are also necessary. (The rhs of := is an l-value. As is the operand to \.)
With that in mind, Perl could construct lvalue operations (those with auto-vivify) from rvalue operations (without auto-vivify). But the reverse isn't true. So the no-auto-vivify semantics are the one that must be preserved. Which contradicts your point that set Pn, Pm[...] should always auto-vivify to support reference semantics. But, really, both are significantly needed—$str = $hash{key} and $ref = \$hash{key} and $str := $hash{key} and $hash{key} := $str and $hash{key} = $str and $hashB{keyB}{keyC}{keyD} = $hash{key} should all come down to PIR simply and behave as in Perl 5 (where the construct exists in Perl 5). Element lookup in an rvalue context should return an anonymous PerlUndef, probably? In an lvalue context, it should do what you're asking for.
But my reading of [1] is not at all the same as this...
$hash{a} = "yyy\n"; $y = \$hash{a}; # = \ --> Brand new reference PMC! print $$y; # yyy $$y = "xxx\n"; print $hash{a}; # xxx
Never mind that there's no PerlReference PMC for $$ to work on, or for \ to return. While Perl 6 could conceivably support reference copying without a reference-type PMC (using :=), it would be pretty darn fragile—one = instead of := and the reference is broken. I would not have translated your original Perl example (with its \) as you did—
actually, I wouldn't be able to translate it at all—\ wants to construct a PerlReference PMC IMO.
—
Gordon Henriksen [EMAIL PROTECTED]