Re: Should Test2 maintain $! and $@?
[email protected] (Kent Fredric) Tue, 12 Jan 2016 16:21:12 +1300
| Newsgroups | perl.cpan.workers |
|---|---|
| Message-ID | <CAATnKFA5W6NT336e=6=gP-VXgVO2Xsgj6Q4n9Xvu7X1B5LsfZQ@mail.gmail.com> |
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