# New Ticket Created by Leopold Toetsch # Please include the string: [perl #15927] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=15927 >
Hi I'm not totally sure, if it's the correct way to go, but it works ;-) I did a test (with a slightly patched P6C, which clones @a = @b). $ cat d.p6 sub main() { my @a = ("x ","y ","z "); my @b = @a; @a[2] = "2 "; @b[0] = "0 "; print @a, @b, "\n"; } $ perl6 -g d.p6 --keep-imc x y 2 0 y z (without patch: 0 y 2 0 y 2 ) and from d.imc #line 3 "d.p6" #@@@@ my @b = @a; _AV_b1 = clone _AV_a1 So patch seems ok, but propably needs more tests in t/pmc. leo -- attachment 1 ------------------------------------------------------ url: http://rt.perl.org/rt2/attach/32597/26897/6446d3/perlarray.pmc.diff
--- parrot/classes/perlarray.pmc Tue Jul 30 18:36:11 2002 +++ parrot-007/classes/perlarray.pmc Thu Aug 1 18:19:12 2002 @@ -78,8 +78,28 @@ } PMC* clone () { - /* XXX */ - return NULL; + PMC* dest; + INTVAL ix, size; + PMC* element; + PMC** array; + + dest = pmc_new(INTERP, enum_class_PerlArray); + dest->vtable = SELF->vtable; + dest->vtable->init(interpreter, dest); + size = SELF->cache.int_val; + resize_array(interpreter, dest, size); + for (ix = 0; ix < size; ix++) { + PMC *new; + array = ((Buffer *) SELF->data)->bufstart; + element = array[ix]; + + if (element) { + new = element->vtable->clone(interpreter, element); + ((PMC**)((Buffer *) dest->data)->bufstart)[ix] = new; + } + + } + return dest; } INTVAL get_integer () {