Re: -w considered harmful
by belg4mit (Prior) on Sep 03, 2002 at 18:55 UTC
|
#!perl -w
{
local $^W = 0;
}
Tada...
Actually IIRC some feel that warnings is harmful.
I never use it personally, for one it's not available
everywhere, also it's not symmetric with -T; but then
again strict isn't with -w. UPDATE: Although I believe
the need to squelch warnings in this manner rather rare.
Basically I wanted to say that -w is evil. It causes code that shouldn't generate warnings to generate
meaningless warnings that the author never intended it to.
Isn't that the point? Catch things you didn't intend?
--
perl -pew "s/\b;([mnst])/'$1/g"
| [reply] [d/l] |
|
Actually IIRC some feel that warnings is harmful.
Ive heard an argument that is while practical still bogus. "Dont use warnings 'cause it isnt backwards compatible." Ok fine, thats a good argument, if you are writing a module that you want or need to have maximum coverage and _must_ be backwards compatible. But if your target enviornment supports warnings then the argument rapidly loses its merit.
Also if you write modules (i write a lot, its part of my job) if you dont use warnings (and write for people using warnings) then you miss out on the power of warnings register. You remove the ability for the end user to specify their warning levels and you turn warnings on in places where the original coder might have specifically omitted them. Thats a PIA IMO.
Isn't that the point? Catch things you didn't intend?
Indeed, I do want things I didn't intend to do come to light. But I dont want to be told about warnings that I _specifically_ discounted. For instance Win32::EventLog works just fine. Use it under -w and it produces errors galore due to dynaloader (I think).
Yves / DeMerphq
---
Software Engineering is Programming when you can't. -- E. W. Dijkstra (RIP)
| [reply] |
|
| [reply] [d/l] [select] |
|
| [reply] |
|
|
I agree that "use warnings"/"no warnings" is far better than the old -w switch. I switched to that as soon as it became available, and never looked back.
| [reply] |
|
| [reply] |
|
| [reply] |
|
Re: -w considered harmful
by Preceptor (Deacon) on Sep 04, 2002 at 09:02 UTC
|
Harmful perhaps, but personally _always_ run my code with 'warnings' on. I've more recently, considered using 'strict' to be the way to go too.
My reasoning is quite simple. It forces me to right 'good' code and not just rely on perl to let me be lazy.
It has also, on occasion, showed me place where I was doing very silly things.
Chasing a warning that makes no sense can be irritating, but then again, so can chasing a bug which makes even less sense....
(My personal favourite was creating a pointer, instead of an array in C. The code would run fine for the first iteration, however, subsequent iterations would _always_ crash. It took me ages to spot why...)
--
It's not pessimism if there is a worse option, it's not paranoia when they are and it's not cynicism when you're right. | [reply] |
|
use strict;
use warnings;
Yves / DeMerphq
---
Software Engineering is Programming when you can't. -- E. W. Dijkstra (RIP)
| [reply] [d/l] |
|
In which case, I stand corrected. (And FWIW I agree).
--
It's not pessimism if there is a worse option, it's not paranoia when they are and it's not cynicism when you're right.
| [reply] |
Re: -w considered harmful
by Foncé (Scribe) on Sep 04, 2002 at 13:41 UTC
|
-w, I've found, is far less useful than the combination of use strict; and use warnings;, anyway. Therefore, I use it very seldom.
Foncé | [reply] [d/l] [select] |