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

[perl #108778] no warnings "module name"

Thread Previous
From:
Father Chrysostomos via RT
Date:
November 20, 2017 00:13
Subject:
[perl #108778] no warnings "module name"
Message ID:
rt-4.0.24-12376-1511136812-1255.108778-15-0@perl.org
On Sun, 19 Nov 2017 12:47:25 -0800, xsawyerx@gmail.com wrote:
> 
> 
> 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.

I think you are missing the fact that these two examples are what currently work to get around the problem.  We already conflate package names with warning categories.


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

Warning registrations are necessarily global.  This is no more action at a distance than the existing:

package Foo;
use warnings::register;

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=108778

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About