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

From: Tassilo v. Parseval (tassilo.von.parseval_at_rwth-aachen.de)
Date: 02/18/05


Date: Fri, 18 Feb 2005 20:09:42 +0100

Also sprach Anno Siegel:

> Tassilo v. Parseval <tassilo.von.parseval@rwth-aachen.de> wrote in comp.lang.perl.misc:

>> 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".

h2xs puts 'use warnings' into the created module skeleton. Those modules
will emit warnings even if -w or warnings are turned off in the program
using this module.

>> 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.

Ah, but there the warning itself becomes the bug. The trivial fix would
be getting rid of 'use warnings' within the module. No warning, hence no
bug. ;-)

There is obviously something very contorted in this logic just outlined.
But it is the direct implication of your assertion that a warning
produced by a module is a bug.

> 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.

I just checked it (again). h2xs puts them in, unless a version older
than 5.6 is specified using -b or --skip-warnings is mentioned
explicitly.

Interestingly enough, I just noticed that I preach things differently
from how I do them in the modules I have released. Most of my modules
have warnings on in fact. I even go through painful procedures to
temporarily switch them off in XS code where necessary and turning them
on again afterwards. Hmmh.

>> 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?

It's not at all clear to me how wrong results correlate with the amount
of warnings emitted. I will admit that the likelihood of warnings is
probably higher when a wrong result is being computed (and vice versa).
However, there will still be many cases where those two things will be
entirely uncorrelated. If anything, warnings from a module will give me
doubts about the quality of the module in question.

>> 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.

I see myself as a plain user when it comes to external modules and
libraries. It is true that in some cases I might lay hands on their code
but in most cases I will start looking for less noisy alternatives. It's
not always practical (let alone easy) to dive into other people's code
and fix things.

Tassilo

-- 
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);


Relevant Pages

  • Re: [PATCH -mm] sys_semctl gcc 4.1 warning fix
    ... I disagree here that it covers up any bug. ... In fact, that wrapper is more ... So if you like to look for real warnings, you can compile it with the ... and have to fight to find the real bugs. ...
    (Linux-Kernel)
  • Re: changed queries save automatically
    ... Not exactly a "tiny" bug is it? ... A query not prompting you about saving it is one of the symptoms of this ... macro or code someone has Set Warnings to Off but forgot to Set ... Compacting and repairing closes the database and reopens it. ...
    (microsoft.public.access.queries)
  • Re: A toughy.
    ... Do I ignore all those warnings and using add and remove just delete the darned thing? ... I have always used HTML for my personal posts and the HTML doesn't seem to ... Bug 2. ... Paying users do not have this message in their emails. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: changed queries save automatically
    ... MS is very aware of this bug, and it's been looked at in many ... Just today I create a new query in A03 ... macro or code someone has Set Warnings to Off but forgot to Set ... Compacting and repairing closes the database and reopens it. ...
    (microsoft.public.access.queries)
  • Re: Why arent warnings on by default?
    ... There is a problem with warnings on a larger scale, ... context of published code, most notably modules. ... Does it mean there's a bug in the module, or maybe in my program using ... If warnings in module context really and rightly suggest there's a bug, ...
    (comp.lang.perl.misc)