Skip to content

Commit

Permalink
Make 'my @A is List = 1,2,3' work
Browse files Browse the repository at this point in the history
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 2bdf2b3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/core/List.pm6
Expand Up @@ -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
Expand Down

0 comments on commit 2bdf2b3

Please sign in to comment.