Subject: | Perl 5.8 compatibility |
attributes.pm in Perl 5.8 before Perl 5.8.9 has a bug where it will also send Perl's own attributes (lvalue, method etc.) to a defined MODIFY_CODE_ATTRIBUTES method and croak, if the MODIFY_CODE_ATTRIBUTES methods does not pretend that it handled them.
Therefore, using Perl's attributes will break on perl 5.8 if Sub::Attribute is loaded. The problem can of course easily be fixed by creating an own MODIFY_CODE_ATTRIBUTES which wrap's Sub::Attributes method and filter's Perl's attributes from the list of attributes it should handle, but if you do not want others to stumble across the same problem, Sub::Attribute should probably itself pretend, that it handled method/lvalue/locked/unique/shared by not returning them, in case Perl sends them.
Just for clarity, here's a Perl source snippet on what I do to restore 5.8 compatiblity with Sub::Attribute:
Therefore, using Perl's attributes will break on perl 5.8 if Sub::Attribute is loaded. The problem can of course easily be fixed by creating an own MODIFY_CODE_ATTRIBUTES which wrap's Sub::Attributes method and filter's Perl's attributes from the list of attributes it should handle, but if you do not want others to stumble across the same problem, Sub::Attribute should probably itself pretend, that it handled method/lvalue/locked/unique/shared by not returning them, in case Perl sends them.
Just for clarity, here's a Perl source snippet on what I do to restore 5.8 compatiblity with Sub::Attribute:
my %builtin = qw(lvalue 1 method 1 locked 1 unique 1 shared 1);
my $old_modify = \&Sub::Attribute::MODIFY_CODE_ATTRIBUTES;
sub MODIFY_CODE_ATTRIBUTES {
my ($pkg, $sub, @attrs ) = @_;
@attrs = grep { !exists $builtin{$_}} @attrs; # work around bugs in perl < 5.8.9
my @tmp;
@tmp = $old_modify->($pkg, $sub, @attrs) if @attrs;
@tmp;
}