Skip to content

Commit

Permalink
Add take-rw, to allow taking of rw containers instead of lvalues.
Browse files Browse the repository at this point in the history
(The existing C<take> function still also returns lvalues... but
now we can start to correct that.)
  • Loading branch information
pmichaud committed May 29, 2011
1 parent b15c9ef commit 048573b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/builtins/control.pir
Expand Up @@ -221,11 +221,19 @@ on the number of elements.
throw e
.end

=item take
=item take and take-rw

=cut

.sub '&take'
.param pmc values :slurpy
x_enter_sublog
values = '&take-rw'(values :flat)
.return (values)
.end


.sub '&take-rw'
.param pmc values :slurpy
x_enter_sublog
.local pmc ex, p6ex
Expand Down
6 changes: 3 additions & 3 deletions src/core/Any-list.pm
Expand Up @@ -59,7 +59,7 @@ augment class Any {
our multi method grep(Mu $test) is rw {
gather {
for @.list {
take $_ if $_ ~~ $test;
take-rw $_ if $_ ~~ $test;
}
}
}
Expand Down Expand Up @@ -273,7 +273,7 @@ augment class Any {
gather for $.list -> $value {
my $key = $i++;
take $key;
take $value;
take-rw $value;
}
}

Expand All @@ -287,7 +287,7 @@ augment class Any {

multi method values() is rw {
gather for $.list -> $value {
take $value;
take-rw $value;
}
}

Expand Down

0 comments on commit 048573b

Please sign in to comment.