Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Difference Between use warnings and use warnings FATAL => 'all'

by tobyink (Canon)
on Dec 27, 2013 at 14:10 UTC ( [id://1068513]=note: print w/replies, xml ) Need Help??


in reply to Re: Difference Between use warnings and use warnings FATAL => 'all'
in thread Difference Between use warnings and use warnings FATAL => 'all'

It really depends on the condition that the warning/error is catching.

For "low fuel", a dashboard light is better than switching off the engine. For "driver has fallen asleep with foot on the accelerator pedal", stopping the car might be a better solution.

If an undef in a variable would led you to deleting every row in a database table, it might be better for the uninitialized warning to be fatal.

Whether a warning can be detected at compile time is another important consideration. Having an unimportant condition cause a long-running process to crash can be awful, but if the same warning prevented it from being started, that would be OK, because it could be fixed straight away. For example, the "void" and "once" warnings categories are detected at compile time, while "numeric" and "uninitialized" are detected at run time.

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

Replies are listed 'Best First'.
Re^3: Difference Between use warnings and use warnings FATAL => 'all'
by BrowserUk (Patriarch) on Dec 28, 2013 at 01:10 UTC
    For "driver has fallen asleep with foot on the accelerator pedal", stopping the car might be a better solution.

    Not really. Wind down the window; play music loud; vibrate the seat or steering wheel; a strident bonging sound; all would be preferable to bringing the car to a sudden halt in the middle of a motorway.

    If an undef in a variable would led you to deleting every row in a database table, it might be better for the uninitialized warning to be fatal.

    It's hard for me to imagine how that would occur, but if it is a possibility, then I might resort to use warnings FATAL => 'uninitialized'; within some limited scope(s); but never FATAL => 'all'.

    I routinely eliminate/guard against all warnings in my code as I go along; but when they do occur unexpectedly, seeing whether they are 1-offs or repeated, whether once they start, they persist or are occasional transients; and where the code goes and what other knock-on warnings arise as a result; all assist in the postmortem of working out what went wrong and what to do about it.

    Even more so when, for example, you get an unhandled transient warning induced by bad data in a long-running, unattended process.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^3: Difference Between use warnings and use warnings FATAL => 'all'
by educated_foo (Vicar) on Dec 28, 2013 at 02:10 UTC
    If an undef in a variable would led you to deleting every row in a database table, it might be better for the uninitialized warning to be fatal.
    This is why you put in thorough sanity checks before doing something so destructive:
    if (defined $thing) { destroy_database($thing); } else { do_something_else(); }
    undef has well-defined semantics in Perl (empty or zero), which are very useful in most cases. You should know when your code may do something catastrophic, and be very careful then, but that's no reason to be paranoid everywhere.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1068513]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-03-29 06:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found