List Info

Thread: Exporter Warning Mystery




Exporter Warning Mystery
user name
2007-03-09 11:55:24
This makes no sense to me:

$ cat E.pl 
#!perl -w
use Exporter;
BEGIN {
    package Testing::Unused::Vars;
    ISA = qw(Exporter);
    EXPORT = qw(this $TODO that);

    package Foo;
    Testing::Unused::Vars->import;
}
__END__
$ ./perl -Ilib E.pl 
Name "Testing::Unused::Vars::TODO" used only once:
possible typo at lib/Exporter/Heavy.pm line 205.
$ ./perl E.pl 
$


Why does it warn if it's reading its libraries from the
build tree, but not
when they're installed?

Same for blead, maint and release 5.8.8

Nicholas Clark

Re: Exporter Warning Mystery
user name
2007-03-09 12:11:41
On 09/03/07, Nicholas Clark <nickccl4.org> wrote:
> Should we fix Exporter not to warn? Rather than relying
on "performance hack"
> to keep it quiet?

Yes, that would be a bug. And looking at the code, the
performance
hack is really hackish.

Re: Exporter Warning Mystery
user name
2007-03-10 06:38:47
On Fri, Mar 09, 2007 at 07:11:41PM +0100, Rafael
Garcia-Suarez wrote:
> On 09/03/07, Nicholas Clark <nickccl4.org> wrote:
> >Should we fix Exporter not to warn? Rather than
relying on "performance 
> >hack"
> >to keep it quiet?
> 
> Yes, that would be a bug. And looking at the code, the
performance
> hack is really hackish.

The test suite visits it 28 times:

   1387        28                        file = GvFILE(gv);
   1388                                  /* performance
hack: if filename is absolute and it's a standard
   1389                                   * module, don't
bother warning */
   1390                  #ifdef MACOS_TRADITIONAL
   1391                  # define LIB_COMPONENT
":lib:"
   1392                  #else
   1393                  # define LIB_COMPONENT
"/lib/"
   1394                  #endif
   1395        28                        if (file
   1396                                      &&
PERL_FILE_IS_ABSOLUTE(file)
   1397                                      &&
(instr(file, LIB_COMPONENT) || instr(file,
".pm")))
   1398                                  {
   1399        28                            continue;
   1400                                  }
   1401        28                       
CopLINE_set(PL_curcop, GvLINE(gv));
   1402                  #ifdef USE_ITHREADS
   1403                                  CopFILE(PL_curcop)
= (char *)file; /* set for warning */
   1404                  #else
   1405        28                       
CopFILEGV(PL_curcop) = gv_fetchfile(file);
   1406                  #endif
   1407        28                        Perl_warner(aTHX_
packWARN(WARN_ONCE),
   1408                                          "Name
"%s::%s" used only once: possible typo",
   1409                                         
HvNAME_get(stash), GvNAME(gv));
   1410                              }
   1411                          }
   1412                      }

http://www.maddingue.net/perlcover/cover1/cover_db
/--gv-c.html

It appears to have been added with change 4545

Change 4545 by gsaronru on 1999/11/11 06:04:20

        another change towards a shareable optree: avoid
pointer to filegv
        in COP; revert parts of change#4485 and
s/xcv_filegv/xcv_file/
        (CvFILE() may yet come in handy somewhere); adjust
compiler doodads
        to suit

http://public.activestate.com/cgi-bin/perlbrowse/p/4545


I'm wondering, should we remove it?

Nicholas Clark

Re: Exporter Warning Mystery
user name
2007-03-10 06:45:48
On 10/03/07, Nicholas Clark <nickccl4.org> wrote:
> It appears to have been added with change 4545
>
> Change 4545 by gsaronru on 1999/11/11
06:04:20
>
>         another change towards a shareable optree:
avoid pointer to filegv
>         in COP; revert parts of change#4485 and
s/xcv_filegv/xcv_file/
>         (CvFILE() may yet come in handy somewhere);
adjust compiler doodads
>         to suit
>
> http://public.activestate.com/cgi-bin/perlbrowse/p/4545
>
>
> I'm wondering, should we remove it?

I'm not against that.

I also wonder, how much new warnings will appear if we
remove it ?
probably not much, given that the core test suite doesn't
generate
them; but maybe in other modules.

Re: Exporter Warning Mystery
user name
2007-03-10 09:26:36
On Sat, Mar 10, 2007 at 01:45:48PM +0100, Rafael
Garcia-Suarez wrote:
> On 10/03/07, Nicholas Clark <nickccl4.org> wrote:
> >It appears to have been added with change 4545
> >
> >Change 4545 by gsaronru on 1999/11/11
06:04:20
> >
> >        another change towards a shareable optree:
avoid pointer to filegv
> >        in COP; revert parts of change#4485 and
s/xcv_filegv/xcv_file/
> >        (CvFILE() may yet come in handy somewhere);
adjust compiler doodads
> >        to suit
> >
> >http://public.activestate.com/cgi-bin/perlbrowse/p/4545
> >
> >
> >I'm wondering, should we remove it?
> 
> I'm not against that.
> 
> I also wonder, how much new warnings will appear if we
remove it ?
> probably not much, given that the core test suite
doesn't generate
> them; but maybe in other modules.

I wondered the same.
Warnings that appear are bugs that were hidden, in my
opinion. Particularly
pernicious bugs, as the warnings won't be suppressed if the
module isn't
installed in a "regular" path. It might cause
someone a lot of angst, trying
to work out why code does(n't) warning, depending on which
machine it's run
on.

Nicholas Clark

Re: Exporter Warning Mystery
user name
2007-04-16 18:01:36
On Sat, Mar 10, 2007 at 03:26:36PM +0000, Nicholas Clark
wrote:
> I wondered the same.
> Warnings that appear are bugs that were hidden, in my
opinion. Particularly
> pernicious bugs, as the warnings won't be suppressed if
the module isn't
> installed in a "regular" path. It might cause
someone a lot of angst, trying
> to work out why code does(n't) warning, depending on
which machine it's run
> on.

OK. I removed it with change 30969.

Nicholas Clark

[1-6]

about | contact  Other archives ( Real Estate discussion Medical topics )