On 12 January 2016 at 16:14, Chad Granum <[email protected]> wrote:
> That said, it just occured to me that this can possibly be accomplished by
> having a context store $! And $@ when it is obtained, then restore them when
> it is released, which would avoid needing to use local everywhere, and still
> preserve them for all tools automatically...
As written, that suggestion scares me slightly, because its behaviour
wouldn't be entirely obvious that it does that.
I'd be fine with a system like:
my $error_state = save_errors();
...
restore_errors($error_state);
return $value;
Or
return preserve_errors(sub{
/* code that can generate errors that shouldn't leak */
});
Just lumping it in with the "Context" object seems too magical.
--
Kent
KENTNL - https://metacpan.org/author/KENTNL