# New Ticket Created by "Carl Mäsak" # Please include the string: [perl #76242] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=76242 >
<masak> rakudo: my $a = [1, 2, 3]; foo($a); bar($a); sub foo(@a) { say @a.perl }; sub bar(@a is copy) { say @a.perl } <p6eval> rakudo 05684c: OUTPUT«[1, 2, 3][[1, 2, 3]]» <masak> that one's new, isn't it? * masak submits rakudobug <pmichaud> masak: that one is interesting. I'm not sure it's a bug. <mathw> pmichaud: it is quite surprising... <masak> pmichaud: oh, come on! :/ <mathw> although I suspect flattening would hide it in many cases <pmichaud> my $a = [1,2,3]; my @b = $a; say @b.perl; <masak> pmichaud: er. put differently, where does the spec say "putting 'is copy' on an array gives you an extra layer of array"? <moritz_> rakudo: sub bar(@a is copy) { say @a.perl }; say bar [1, 2, 3] <p6eval> rakudo 05684c: OUTPUT«[[1, 2, 3]]1» <moritz_> pmichaud: that's assignment <moritz_> pmichaud: signature binding is *binding* <pmichaud> moritz_: except for is_copy <pmichaud> it's the same logic by which <pmichaud> my $b = [1,2,3]; sub xyz($x is copy) { $x[1] = 'b'; }; xyz($b); say $b.perl; <pmichaud> rakudo: my $b = [1,2,3]; sub xyz($x is copy) { $x[1] = 'b'; }; xyz($b); say $b.perl; <p6eval> rakudo 05684c: OUTPUT«[1, "b", 3]» <pmichaud> anyway, I can fix it. <pmichaud> I agree that the other interpretation likely makes more sense. <masak> rakudo: my $a = 5; sub bar(@a is copy) { say @a.perl }; bar($a) <p6eval> rakudo 05684c: OUTPUT«Nominal type check failed for parameter '@a'; expected Positional but got Int instead in 'bar' [...] <masak> pmichaud: if the above doesn't bind, why does my first line give double arrays? <masak> seems very arbitrary. <pmichaud> I just said I wasn't certain of it. :-) <masak> just trying to make you even less certain :P <pmichaud> the "is copy" logic is still not completely nailed down, based on discussion with TimToady++ at yapc::na <masak> I do see the parallel with attr arrays and :attr[]. by the way. <pmichaud> anyway, the one thing I *am* certain of is that "is copy" is not "binding". Indeed, the whole point of "is copy" is to avoid the bind. :-) <mathw> yes that's what I thought :) <moritz_> I thought it copied, and then binds <pmichaud> okay, one can think of it that way. :-) <pmichaud> but it's not binding to the argument <pmichaud> in the same way, my @b = $a; is a bind only in the sense that we bind he symbol '@b' to an array before doing the assign <pmichaud> anyway, I know the fix. Should be one-line :) <pmichaud> did the ticket get filed yet?