Skip Menu |

This queue is for tickets about the Class-Classless CPAN distribution.

Report information
The Basics
Id: 4527
Status: new
Priority: 0/
Queue: Class-Classless

People
Owner: Nobody in particular
Requestors: nothingmuch [...] woobling.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.34
Fixed in: (no value)



Subject: $obj->can doesn't return code ref
UNIVERSAL::can returns a code ref on success, not one. I use this a lot with goto. I wanted to test where i was killing other modules, and i needed to patch as follows: 1308c1308 < return 1 --- Show quoted text
> return sub { $Class::Classless::X::AUTOLOAD = "::" . $m; goto &Class::Classless::X::AUTOLOAD }
Enjoy
From: nothingmuch [...] woobling.org
This new patch will differentiate between static method and code ref ones. It also has a commented out part where a cache of anonysubs for static methods can be stored, but I think that's a bad thing to do - the reasons are also in the comments. Best of luck
1308,1310c1308,1319 < return 1 < if ref($o->{'METHODS'} || 0) # sanity < && exists $o->{'METHODS'}{$m}; --- > if (ref ($o->{'METHODS'} || 0) && exists $o->{'METHODS'}{$m}){ > if (ref $o->{'METHODS'} eq 'CODE'){ > return $o->{'METHODS'}{$m}; > } else { > # $o->{'STATIC_METHOD_CODEREFS'}{$m} ||= sub { $Class::Classless::X::AUTOLOAD = $m; goto &Class::Classless::X::AUTOLOAD }; > # return $o->{'STATIC_METHOD_CODEREFS'}{$m}; > # the above is good for when you need to compare code refs, but that doesn't happen a lot. > # the cons is an uglier namespace, deletion and redefinition of methods will break > # and it's excessive. I prefer a simple: > return sub { $Class::Classless::X::AUTOLOAD = $m; goto &Class::Classless::X::AUTOLOAD } > } > } 1313c1322 < return 0; --- > return undef;