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

Re: [perl #108778] no warnings "module name"

Thread Next
From:
Zefram
Date:
November 15, 2017 09:59
Subject:
Re: [perl #108778] no warnings "module name"
Message ID:
20171115095915.GM4913@fysh.org
Father Chrysostomos wrote:
>It should be possible to disable a warnings category before it is
>registered,

We could implement that by implicitly registering any warnings
category that gets mentioned in order to assign a slot in the bitset.
But accepting not-yet-registered would mean losing all protection
on warning pragmata against typos and naming mistakes.  If we were
to do that, 'use warnings "nuemric"' and 'use warnings "syscall"'
*would* proliferate.  When the type is on a "use warnings", it means
the programmer wouldn't get warnings that ey thought ey would get,
which would encourage the development of subtle bugs.

So I think we have to insist on explicit registration.  A module that
knows it's going to refer to a non-core warnings category, and doesn't
know that it'll already be registered, could explicitly register the
category itself.  Registration is idempotent, so there's no problem of
clashing with the `real' registration.  It does mean that modules need
to be aware of which categories they mention are non-core, but that's
not too bad a downside for a relatively rare requirement.

>Also, `use warnings' doesn't enable overload warnings unless overload.pm
>is already loaded.

That sounds more like a real bug.  It needs to be addressed by changing
the treatment of short bitsets (not containing whichever bit we're trying
to look at).

-zefram

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