develooper Front page | perl.perl5.porters | Postings from December 2017

Re: [perl #126085] Not expected arguments for $SIG{__WARN__} handler

Thread Previous | Thread Next
From:
Zefram
Date:
December 16, 2017 10:23
Subject:
Re: [perl #126085] Not expected arguments for $SIG{__WARN__} handler
Message ID:
20171216102254.GZ25404@fysh.org
KES via RT wrote:
>Are you speaking about warnings or exceptions here?

Both.  The subject of warn() is an exception, in the sense of being a
notable program state that is being reported non-locally.  The difference
between warn() and die() is not in whether their subject is an exception,
but in whether the code reporting the exception is prepared to continue.
We have plenty of code that shuffles exceptions between the warning and
dying mechanisms.

>The message given to the warnings systems is $@, is not?

warn() can take an exception from $@, but within the warning system the
exception being warned about is generally not in $@.  The $SIG{__WARN__}
handler gets the exception as an argument.  For that matter, the
$SIG{__DIE__} handler also gets the exception as an argument.  The primary
purpose of $@ is quite a limited one: to communicate a caught exception
or lack thereof from "eval" to the code that runs immediately after.

-zefram

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About