Skip Menu | You are currently an anonymous guest. | Login | Return to Main | About rt.cpan.org
 

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.

X Report information
Id: 41638
Status: resolved
Left: 0 min
Priority: 0/0
Queue: Attribute-Util

Owner: Nobody
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

Severity: (no value)
Broken in: (no value)
Fixed in: (no value)




X History Display mode: Brief headersFull headers
#   Thu Dec 11 16:04:26 2008 user42[...]zip.com.au - Ticket created  
Subject: Attribute::Memoize from a "require"d module
Date: Fri, 12 Dec 2008 08:03:21 +1100
To: bug-Attribute-Util[...]rt.cpan.org
From: Kevin Ryde <user42[...]zip.com.au>
[text/plain 646b]
With Attribute-Util 1.03, Attribute::Handlers 0.81 and debian perl
5.10.0, the sample program and module below get an error

loading bar ...
Can't use string ("ANON") as a symbol ref while "strict refs" in use at /usr/share/perl5/Attribute/Memoize.pm line 13.
BEGIN failed--compilation aborted at bar.pm line 9.
Compilation failed in require at foo.pl line 7.

Changing foo.pl from "require bar" to "use bar" makes it run ok.

I suspect it may be the Attribute::Handlers problem with later loaded
modules (already reported). Unless Attribute::Memoize needs some extra
incantation to be able to mung new funcs at the right time.


[text/x-perl 185b]
use Attribute::Memoize;
use strict;
use warnings;
use lib '.';

print "loading bar ...\n";
require bar;
print "bar is loaded\n";
print bar::func(),"\n";
print bar::func(),"\n";
exit 0;

[text/x-perl 127b]
package bar;
use strict;
use warnings;
use Attribute::Memoize;

sub func : Memoize {
print "func runs\n";
return 123;
}
1;

#   Sun Feb 08 04:12:38 2009 DANKOGAI - Correspondence added  
[text/plain 1.2k]
Thanks you for your report. As a matter of fact this has been that way w/ old
Attribute::Handlers as well since:

perldoc Attribute::Handlers
> By default, attribute handlers are called at the end of the compilation
> phase (in a "CHECK" block). This seems to be optimal in most cases
> because most things that can be defined are defined by that point but
> nothing has been executed.

in other words, it is too late to 'require'. Just 'use foo' and it works fine.

Dan the Maintainer Thereof


On Thu Dec 11 16:04:26 2008, user42[...]zip.com.au wrote:
> With Attribute-Util 1.03, Attribute::Handlers 0.81 and debian perl
> 5.10.0, the sample program and module below get an error
>
> loading bar ...
> Can't use string ("ANON") as a symbol ref while "strict refs" in
> use at /usr/share/perl5/Attribute/Memoize.pm line 13.
> BEGIN failed--compilation aborted at bar.pm line 9.
> Compilation failed in require at foo.pl line 7.
>
> Changing foo.pl from "require bar" to "use bar" makes it run ok.
>
> I suspect it may be the Attribute::Handlers problem with later loaded
> modules (already reported). Unless Attribute::Memoize needs some
> extra
> incantation to be able to mung new funcs at the right time.
>




#   Sun Feb 08 04:12:38 2009 RT_System - Status changed from 'new' to 'open'  
#   Sun Feb 08 04:12:41 2009 DANKOGAI - Status changed from 'open' to 'resolved'  
#   Thu Feb 12 18:02:51 2009 user42[...]zip.com.au - Correspondence added  
Subject: Re: [rt.cpan.org #41638] Attribute::Memoize from a "require"d module
Date: Fri, 13 Feb 2009 10:00:44 +1100
To: bug-Attribute-Util[...]rt.cpan.org
From: Kevin Ryde <user42[...]zip.com.au>
[text/plain 587b]
"DANKOGAI via RT" <bug-Attribute-Util[...]rt.cpan.org> writes:
>
> it is too late to 'require'.

You could put that (ie. doesn't work with "require") as a caveat in the
docs of affected modules (Attribute::Memoize and whichever other), since
it's fairly subtle.

Put the blame at the feet of Attribute::Handlers, since I guess it's not
easily fixable, and even then would afflict users of plain 5.8.x and
5.10.0 with the supplied Attribute::Handlers. I guess the present
attributes implementation is more geared to manipulating the coderef
than the name/binding of the sub it's created as.

#   Thu Feb 12 18:02:52 2009 RT_System - Status changed from 'resolved' to 'open'  
#   Tue Mar 24 09:33:28 2009 DANKOGAI - Correspondence added  
[text/plain 741b]
On Thu Feb 12 18:02:51 2009, user42[...]zip.com.au wrote:
> "DANKOGAI via RT" <bug-Attribute-Util[...]rt.cpan.org> writes:
> >
> > it is too late to 'require'.
>
> You could put that (ie. doesn't work with "require") as a caveat in the
> docs of affected modules (Attribute::Memoize and whichever other), since
> it's fairly subtle.
>
> Put the blame at the feet of Attribute::Handlers, since I guess it's not
> easily fixable, and even then would afflict users of plain 5.8.x and
> 5.10.0 with the supplied Attribute::Handlers. I guess the present
> attributes implementation is more geared to manipulating the coderef
> than the name/binding of the sub it's created as.

So I did in version 1.04. Closing ticket.

Dan the Maintainer Thereof



#   Tue Mar 24 09:33:29 2009 DANKOGAI - Status changed from 'open' to 'resolved'