From: Leopold Toetsch <[EMAIL PROTECTED]> Date: Mon, 25 Apr 2005 08:59:05 +0200
Bob Rogers <[EMAIL PROTECTED]> wrote: > From: Leopold Toetsch <[EMAIL PROTECTED]> > It probably just depends on the implementation of Perl5 references. > Hmm. I'm probably missing something (it wouldn't be a first), but if > the reference points to $a itself rather than the PMC to which $a > refers, then you could implement this without morphing, at the cost of > an extra indirection for each Perl deref. Yep, I was thinking about that too. The cost of one indirection per deref is really small. The problem with that approach is: what does "$a" mean. It's currently a slot in the ScratchPad PMC, which is an OrderedHash. By adding more lexicals this ScratchPad PMC is likely to resize, which can easily change the location of the "$a" PMC. Combined with my proposal that the lexicals storage is part of the persistent register range, this approach would be trivial . . . You've lost me here. But I take your point that it's a manageable problem. > But, without PMC morphing, referencing the middle of an array is more > problematic: > my @b = (1, 2, 3); > my $c = \$b[1]; > $$c *= 4; > # prints "1 8 3\n". > print(join(' ', @b), "\n"); > To make this work, $c would need to contain a pointer (i.e. a reference > PMC) into the middle of @b, which could be trickier for GC. Not really. The ref "$c" can be a bound Key PMC that contains the array and the index (where index is an arbitrary possibly nested Key). Oh, yes; I had forgotten about Key PMCs. Yes, that would do nicely. A special class could even handle references into OrderedHash instances, but that would likely be suboptimal. > You may be way ahead of me here, but I am beginning to think that a > morph-free Parrot might be feasible. I am going out on a limb to > suggest all of this because, IMHO, it might make Parrot simpler and more > robust overall, and certainly ought to interoperate better between Perl > and non-Perl. Yeah. Interoperbility is another strong argument. Having a mixture of morphing and immutable (scalar) PMCs could really be dangerous. > So, tell me, what have I missed? I don't think that you missed something. leo Good; that means I'm learning. ;-} Maybe some day I'll know enough to be able to help implement such a thing . . . -- Bob