develooper Front page | perl.perl5.porters | Postings from May 2013

Re: RFC 'used only once' warnings shouldn't affect (some?) internalpackages

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
May 14, 2013 09:42
Subject:
Re: RFC 'used only once' warnings shouldn't affect (some?) internalpackages
Message ID:
20130514094243.GU3729@plum.flirble.org
On Tue, May 14, 2013 at 06:10:21AM -0300, Brian Fraser wrote:
> This is annoying:
> 
> $ perl -Mwarnings -e 'require Config; if (!$Config::Config{d_foo}) {
> *CORE::GLOBAL::glob = sub {} }'
> Name "CORE::GLOBAL::glob" used only once: possible typo at -e line 1.
> Name "Config::Config" used only once: possible typo at -e line 1.
> 
> I'm thinking that anything under %CORE::GLOBAL:: and *Config::Config should
> have the MULTI flag automatically set in gv.c, so this warning won't happen
> for them. I can provide a patch, but perhaps there's other packages that
> should have the same treatment?

CORE::GLOBAL:: does have relevance to the internals, but Config:: is just
package with a use determined by convention, much like strict or B. It's
not fundamentally part of the internals.

Why does Config deserve a special case?
And, if others deserve it too, where does the special case list stop?

If that list is open-ended, this doesn't feel like the right solution to
the problem.

What you're proposing also doesn't solve this one:

$ ./perl -Ilib -w lib/FindBin.pm 
Name "FindBin::again" used only once: possible typo at lib/FindBin.pm line 168.
$ ./perl -Ilib -w -e 'use FindBin'


that "used only once" warnings only happen in the main program. Which, IIRC,
is not documented, and put in as a hack to avoid warnings from modules which
legitimately have package variables used only once, but named in their
EXPORT lists.


The two feel that they should be related. Although, really, it seems to boil
down to the fact that the warning is triggering for valid reasons, but the
programmer wants to say "thanks, but I know better" but refuses to type
C<no warnings 'once';>

Nicholas Clark

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