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

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

Thread Previous | Thread Next
From:
Sawyer X
Date:
November 19, 2017 20:47
Subject:
Re: [perl #108778] no warnings "module name"
Message ID:
b4e91a00-4dd7-2cfa-6d7b-74a46af39b1d@gmail.com


On 11/19/2017 09:07 PM, Father Chrysostomos wrote:
> 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';

Please don't. This mixes the import specification for warning categories
with classes. These are distinct things that should be kept apart.

> Do you think it would be reasonable to add a REGISTER directive, similar to FATAL?
>
> use warnings;
> no warnings 'once' , REGISTER => "Hash::Util";

Not as bad, but worries me about action at a distance.

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

I'll second 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