Skip to content

Commit

Permalink
allow whenever blocks to use redo
Browse files Browse the repository at this point in the history
  • Loading branch information
timo committed Jan 20, 2017
1 parent f97d5c2 commit 0a0508d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/core/Supply.pm
Expand Up @@ -1683,9 +1683,20 @@ sub SUPPLY(&block) {
$state.run-operation({
my &*ADD-WHENEVER = sub ($supply, &whenever-block) {
$state.increment-active();
my $redoable = -> \value {
loop {
nqp::handle(
nqp::stmts(whenever-block(value), last),
'REDO', 0)
}
}
my $tap = $supply.tap(
-> \value {
self!run-supply-code({ whenever-block(value) }, $state)
self!run-supply-code({
nqp::handle(
whenever-block(value),
'REDO', $redoable(value))
}, $state)
},
done => {
$state.delete-active-tap($tap) if $tap.DEFINITE;
Expand Down

0 comments on commit 0a0508d

Please sign in to comment.