Re: Why aren't 'warnings' on by default?

From: Anno Siegel (anno4000_at_lublin.zrz.tu-berlin.de)
Date: 02/18/05


Date: 18 Feb 2005 17:57:16 GMT

Tassilo v. Parseval <tassilo.von.parseval@rwth-aachen.de> wrote in comp.lang.perl.misc:
> Also sprach Anno Siegel:
> > <nospam@geniegate.com> wrote in comp.lang.perl.misc:

> >> sub something {
> >> my($i);
> >> {
> >> my($i)
> >> .. use inner $i ...
> >> }
> >> ... use outer $i ..
> >> }
> >
> > It doesn't warn (why didn't you test it?) and it never did. That is
> > no reason not to use warnings.
>
> There is a problem with warnings on a larger scale, namely in the
> context of published code, most notably modules. It's most annoying and
> fairly useless to read things such as
>
> Use of uninitialized value in string eq at
> /opt/perl5.8.6-db/lib/5.8.6/Foo/Bar/Baz.pm line 4242

Okay, but that happens only with global -w, not with lexical "use warnings".

> Does it mean there's a bug in the module,

Yes. See below.

> or maybe in my program using
> this module? Or maybe it's a potential bug that could occur under
> certain rare circumstances. It could just as easily mean nothing of that
> kind and only expose the module's author's sloppyness.

If a module issues warnings the author didn't intend the user to see,
that's a bug. Most of the time it is trivially fixed.

If the module author has "use warnings" early in each file as a matter of
course, these problems are caught during development. Unfortunately, h2xs
issues a module template without warnings. That may be a reason why the
practice isn't more common.

> If warnings in module context really and rightly suggest there's a bug,
> then the bug itself will sooner or later manifest in some other way,
> wont it? Otherwise it wouldn't be one.

What about silently delivering wrong results?

> The point being that warnings
> rarely provide information useful to people not in charge of the code.

Really? I'd understand "(not) useful to the people running the program",
but as a developer I'm just as interested in warnings as I am in errors.

Anno



Relevant Pages