From b6afa71277c6f0405a1fb31976fb8aa70310b5a3 Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Wed, 25 Dec 2019 14:36:17 +0100 Subject: [PATCH] Add is-lazy named to `gather` iterator 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 --- src/core.c/Rakudo/Iterator.pm6 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core.c/Rakudo/Iterator.pm6 b/src/core.c/Rakudo/Iterator.pm6 index 4f21f01a22a..e50996b468f 100644 --- a/src/core.c/Rakudo/Iterator.pm6 +++ b/src/core.c/Rakudo/Iterator.pm6 @@ -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 := { @@ -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