Skip to content

Commit

Permalink
Introduce "done foo" as shortcut for "emit foo; done" (#4412)
Browse files Browse the repository at this point in the history
As discussed in Raku/problem-solving#249

This makes the "done" sub a multi and adds a candidate that does an `emit` of the value, before actually doing a `done`.
  • Loading branch information
lizmat committed Jun 18, 2021
1 parent 292e8c8 commit 452e92e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core.c/control.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,14 @@ sub emit(Mu \value --> Nil) {
nqp::setextype($ex,nqp::const::CONTROL_EMIT);
nqp::throw($ex);
}
sub done(--> Nil) {
proto sub done(|) {*}
multi sub done(--> Nil) {
THROW-NIL(nqp::const::CONTROL_DONE);
}
multi sub done(Mu \value --> Nil) {
emit value;
done;
}

proto sub die(|) {*};
multi sub die(--> Nil) {
Expand Down

0 comments on commit 452e92e

Please sign in to comment.