> On 28 Oct 2018, at 01:51, Norman Gaywood <ngayw...@gmail.com> wrote: > Just been reading the latest of Elizabeth's wonderful blog posts on how > phasers work in perl6: > https://opensource.com/article/18/10/how-phasers-work-perl-6 > > 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. Liz