develooper Front page | perl.perl6.users | Postings from October 2018

Re: KEEP/UNDO phaser question

Thread Previous
Elizabeth Mattijsen
October 28, 2018 09:21
Re: KEEP/UNDO phaser question
Message ID:
> On 28 Oct 2018, at 01:51, Norman Gaywood <> wrote:
> Just been reading  the latest of Elizabeth's wonderful blog posts on how phasers work in perl6:
> I have question on the KEEP/UNDO example:
> {
>     KEEP $dbh.commit;
>     UNDO $dbh.rollback;
>     ...    # set up a big transaction in a database
>     True;  # indicate success
> }
> Won't that "True;  # indicate success" just force the KEEP phaser to run? Shouldn't you just use the result of  whatever  is the result of "... # set up a big transaction in a database"?

That it would indeed.  The theory behind that is that if you got there, all went ok.  And that if anything went wrong in the … , you would have either returned False or thrown an exception.

You’re right, it can be a variable holding a result as well, of course.  But I also wanted to convey the fact that if the block was exited in some other way (usually with an exception), it would run the UNDO phaser.

I guess I could have been more explicit.

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About