Skip to content

Commit

Permalink
Introduce :is-lazy named for gather { } blocks
Browse files Browse the repository at this point in the history
After this commit, you can indicate that your `gather` block is to
be treated as a lazy one:

    gather {
        ...
    } :is-lazy;
  • Loading branch information
lizmat committed Dec 25, 2019
1 parent b6afa71 commit 07072f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/core.c/Rakudo/Iterator.pm6
Expand Up @@ -1858,6 +1858,8 @@ class Rakudo::Iterator {
$n
)
}

method is-lazy() { $!is-lazy }
}
method Gather(&block, :$is-lazy) { Gather.new(&block, $is-lazy.Bool) }

Expand Down
4 changes: 3 additions & 1 deletion src/core.c/Seq.pm6
Expand Up @@ -178,7 +178,9 @@ my class Seq is Cool does Iterable does Sequence {
}
}

sub GATHER(&block) { Seq.new(Rakudo::Iterator.Gather(&block)) }
sub GATHER(&block, :$is-lazy) {
Seq.new(Rakudo::Iterator.Gather(&block, :$is-lazy))
}

multi sub infix:<eqv>(Seq:D \a, Seq:D \b) {
nqp::hllbool(
Expand Down

0 comments on commit 07072f3

Please sign in to comment.