in reply to Re^8: Net::SSH2 test connection to remote host
in thread Net::SSH2 test connection to remote host
DESTROY methods should not have side effects like changing $@ unless they do it while dieing
In other words, I have no problem if some DESTROY method dies and changes $@ while doing it.
In practice, what I mean is that inside a DESTROY sub, if eval is used, $@ should be localized for its scope (and the same applies for $! and IO operations and $? and system, fork, etc.)
For instance, I see no problem with this DESTROY method:
sub DESTROY { my $self = shift; { local $@; eval { $self->whatever() }; } die "cleanup failed" unless $self->cleanup; }
Regarding the p5p discussion, it was about whether this no-side-effects-from-DESTROY thing should be implemented at the interpreter level.
|
|---|