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

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

Thread Next
From:
KES via RT
Date:
December 16, 2017 10:04
Subject:
[perl #126085] Not expected arguments for $SIG{__WARN__} handler
Message ID:
rt-4.0.24-21697-1513418533-1473.126085-15-0@perl.org
Zefram, thank you for clarifying the DOC. But one question:

>+By default, the exception derived from the operand LIST is stringified
+and printed to C<STDERR>.  This behaviour can be altered by installing
+a L<C<$SIG{__WARN__}>|perlvar/%SIG> handler.  If there is such a
+handler then no message is automatically printed; it is the handler's
+responsibility to deal with the exception

Are you speaking about warnings or exceptions here? if you are speaking about exceptions then "a L<C<$SIG{__DIE__}> handler" should be installed instead of $SIG{__WARN__}.
But I will be happy if warnings and exceptions are treated the same and handled the same way with only one difference: warnings are not fatal


Aristotle Pagaltzis
> The job of `warn` is to take its arguments and turn them into a message for the warning system
As I see from documentation it is "stuffed into $@"

>If you want to intercept the arguments to `warn`, then that is what you need to do – not intercept the messages given to the warnings system

The message given to the warnings systems is $@, is not?
The handler is called up to "rewrite" a pending warning in $@" and this messages is rewritten as more accurate as more context information it has. 

So I will advocate to that that handler should be called with original LIST

>Chapter “Overriding Built-in Functions” in `perldoc perlsub` explains your options. (And you’re in luck: `warn` is easy to override. This is absolutely not true for some other built-ins.)

Never thought about overloading because "this behaviour can be altered by installing a L<C<$SIG{__WARN__}>|perlvar/%SIG> handler." so maybe there will be a good point to describe the difference between installing the handler and overloading the CORE::warn

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=126085

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