Skip to content
Permalink
Browse files

Make 'my @A is List = 1,2,3' work

Add a candidate for LIST.STORE(:$initialize!), which does not interfere
with the normal use of List.STORE that is used for ($a,$b,$c) = 1,2,3
  • Loading branch information...
lizmat committed Sep 24, 2018
1 parent 43919c6 commit 2bdf2b35a14243c257d439219e08b3867ff8acf2
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/core/List.pm6
@@ -756,6 +756,17 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
# Store in List targets containers with in the list. This handles list
# assignments, like ($a, $b) = foo().
proto method STORE(List:D: |) {*}
multi method STORE(List:D: Iterable:D \iterable, :$initialize!) {
if $initialize {
my \buffer := nqp::create(IterationBuffer);
iterable.iterator.push-all(buffer);
nqp::p6bindattrinvres(self,List,'$!reified',buffer)
}
else {
self.STORE(iterable);
}
}

multi method STORE(List:D: Iterable:D \iterable) {
# First pass -- scan lhs containers and pick out scalar versus list
# assignment. This also reifies the RHS values we need, and deconts

0 comments on commit 2bdf2b3

Please sign in to comment.
You can’t perform that action at this time.