The magic is already there, but it is there by localizing the vars in a ton
of non obvious places. Between that and having it done in one obvious and
documented place seems like a Much better option.
On Jan 11, 2016 7:21 PM, "Kent Fredric" <kentfred...@gmail.com> wrote:

> On 12 January 2016 at 16:14, Chad Granum <exodi...@gmail.com> 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
>

Reply via email to