develooper Front page | perl.perl5.porters | Postings from July 2020

Re: try/catch and CLEANUP/FINALLY/&c.

Thread Previous | Thread Next
Felipe Gasper
July 17, 2020 14:18
Re: try/catch and CLEANUP/FINALLY/&c.
Message ID:

> On Jul 17, 2020, at 1:31 AM, Felipe Gasper <> wrote:
> Maybe try/catch/finally is actually less useful in general than a CLEANUP that fires at the end of the block that contains the try/catch. I can’t say what’s most useful to a typical Perl developer--much less a “potential” Perl developer.

Postscript to this: In my JS work I typically do things like:

show_notification('Frobnicating …');

try {
catch (e) {
finally {

… in which context I definitely want the “cleanup” logic to fire immediately after the try/catch.

Without a “standard” finally block I could do it with a scope-guard by undef()ing the reference after the catch block. With the proposed CLEANUP {} I’d need an extra code block around the try/catch.

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