Re: Should Test2 maintain $! and $@?

[email protected] (Kent Fredric) Mon, 18 Jan 2016 19:11:43 +1300
Newsgroups perl.cpan.workers
Message-ID <CAATnKFAUFmKfgN8fbAOWToQWY8DdD4C5KvYMcXmWtNd3uLQeRg@mail.gmail.com>
On 18 January 2016 at 19:08, Kent Fredric <[email protected]> wrote:
> You could possibly make it a parameter to ->release
>
> ->release({ no_restore => 1 }) # don't restore anything
> ->release({ no_restore => [qw( $@ )] })  # only avoid restoring $@


Aaaactually it might make more sense on `context()`

my $ctx = context(); # default, preserves all
my $ctx = context({ preserve => undef }); # preserve nothing
my $ctx = context({ preserve => [] }); # preserve nothing
my $ctx = context({ preserve => [qw( $@ )] }); # preserve $@

$ctx->release(); # restores preserved values

Though which is more effective would depend on how its implemented and
how those vars are stored/preserved.

I'll have to dig into the code later maybe.



-- 
Kent

KENTNL - https://metacpan.org/author/KENTNL