develooper Front page | perl.perl5.porters | Postings from October 1999

Re: deprecating SIGDIE

Thread Previous | Thread Next
Joshua N Pritikin
October 1, 1999 11:52
Re: deprecating SIGDIE
Message ID:
On Fri, Oct 01, 1999 at 01:53:05PM -0400, wrote:
> Current situation: as Larry said, you do not need to protect against
> __DIE__.  __DIE__ handler *should not* step on other people's $@.


> However, this "should not" requires some additional work from the
> __DIE__ handler writers.  The above 'local' is in recognition of
> possibility of potentially buggy __DIE__.
> Providing __EXCEPTION__ allows one 
>   a) either document extremely strict requirements on the code;

It should be enforced.  Exceptions are too critical to leave to
(potentially unread!) documentation.

>   b) or make $@ local inside __EXCEPTION__, in pseudocode:
> 	  local $@ = $@;
> 	  $SIG{__EXCEPTION__}->();

Ugh.  That means die within __EXCEPTION__ is not reported except with:

  $SIG{__EXCEPTION__} = sub {
    # local $@=$@;  # Ilya's magic
    eval {
       # ...
       #dangerous stuff
       # ...
    warn if $@;

I guess that's workable but there is still the possibility of leaking
exceptions if the eval {} is forgotten or the "warn if $@" is forgotten.
I hate to allow the possibility of these leaks.  I much prefer

  exit("Exception throw inside $SIG{__EXCEPTION__}");

instead of an implicit "local $@=$@" (which should be outlawed!).  In
fact, I believe I submitted a patch over a year ago for a compile time
warning if $@ is localized.  In my opinion, exiting is far preferable to
any localization of $@.

This exit(...) can always be circumvented with carefully designed
eval{}, anyway.

"Jokes are not funny; doubt is funny."
    via, but not speaking for Deutsche Bank

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About