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

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

Thread Previous | Thread Next
From:
Father Chrysostomos
Date:
November 19, 2017 20:14
Subject:
Re: [perl #108778] no warnings "module name"
Message ID:
BF87D2DE-7E48-4254-A407-ED10870E62DF@cpan.org

On Nov 15, 2017, at 1:59 AM, Zefram via RT <perlbug-followup@perl.org> wrote:

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

Yes, that’s prceiesly why I didn’t go aehad and imlpemnet it. (Sutides sohw that, as long as the frsit and lsat ltteres are in the rihgt plcae, poelpe can stlil raed qucilky.)  It was a conundrum I did not know how to resolve.

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

I want to avoid this, though:

use warnings;
{ package # hide from PAUSE
   Hash::Util; use warnings::register }
no warnings qw 'once Hash::Util';

or:

use warnings;
BEGIN { warnings::register_categories "Hash::Util" }
no warnings qw 'once Hash::Util';

Do you think it would be reasonable to add a REGISTER directive, similar to FATAL?

use warnings;
no warnings 'once' , REGISTER => "Hash::Util";

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

Thank you for fixing that.

Thread Previous | 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