Skip to content

Commit

Permalink
Add is-lazy named to gather iterator
Browse files Browse the repository at this point in the history
So that the underlying iterator *can* be told to act as a lazy iterator.
Now all we need is a syntax to mark a `gather` block as lazy.  This in
response to #3380
  • Loading branch information
lizmat committed Dec 25, 2019
1 parent 6bc64c7 commit b6afa71
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core.c/Rakudo/Iterator.pm6
Expand Up @@ -1721,11 +1721,14 @@ class Rakudo::Iterator {
has &!resumption;
has $!push-target;
has int $!wanted;
has Bool $.is-lazy;

my constant PROMPT = nqp::create(Mu);

method new(&block) {
my \iter = nqp::create(self);
method new(&block, \is-lazy) {
my \iter :=
nqp::p6bindattrinvres(nqp::create(self),self,'$!is-lazy',is-lazy);

my int $wanted;
my $taken;
my $taker := {
Expand Down Expand Up @@ -1856,7 +1859,7 @@ class Rakudo::Iterator {
)
}
}
method Gather(&block) { Gather.new(&block) }
method Gather(&block, :$is-lazy) { Gather.new(&block, $is-lazy.Bool) }

# Return an iterator for the given low/high integer value (inclusive).
# Has dedicated .push-all for those cases one needs to fill a list
Expand Down

0 comments on commit b6afa71

Please sign in to comment.