On Thu, Jul 25, 2013 at 2:07 PM, David E. Wheeler <david@justatheory.com> wrote: > On Jul 25, 2013, at 7:34 PM, David Nicol <davidnicol@gmail.com> wrote: > >> With that use case in mind, having a package catch scope might be good > > Don’t we have a package scope since 5.14 or so if you use a block? > > package Foo { > CATCH { > # BOOM. > } > } that looks like it should get optimized out, with a warning: AFAIK Perl has no syntax construct at this time that would change the scope of something depending on if something else is there or not. package Foo { CATCH { ... recovering from Foo:: error ... } } package Foo { sub riskything{ ... }; CATCH { ... recovering from error in Foo::riskything() } } Another question -- where does a package-scoped Catch return its value to? -- I imagine the answer would be, at the call stack boundary between the package that caught the error and a different package that called it. That would support conventions such as returning -1 for errors implemented like so: FancyNewNetworkLibrary::CATCH { warn "unhandled exception ".shift @@; -1 }Thread Previous | Thread Next