| Sub-Attribute documentation | Contained in the Sub-Attribute distribution. |
Sub::Attribute - Reliable subroutine attribute handlers
This document describes Sub::Attribute version 0.05.
package Attribute::Foo;
use Sub::Attribute;
sub Foo :ATTR_SUB{
my($class, $sym_ref, $code_ref, $attr_name, $attr_data) = @_;
# ...
}
# and later
package main;
use parent qw(Attribute::Foo);
sub something :Foo(xyzzy){
# ...
}
# apply: __PACKAGE__->Foo(\*something, \&something, 'Foo', 'xyzzy')
Sub::Attribute is a role to define attribute handlers for specific
subroutine attributes.
The feature of this module is similar to that of Attribute::Handlers, but
has less functionality and more reliability.
That is, while Attribute::Handlers provides many options for ATTR(CODE),
Sub::Attribute provides no options for ATTR_SUB.
However, the attribute handlers defined by Sub::Attribute are always called
with informative arguments. Attribute::Handlers's ATTR(CODE) is not called
in run-time eval(), so ATTR(CODE) is not reliable.
Defines a method as an subroutine attribute handler.
If true, reports how attributes are applied, using warn() function.
Perl 5.8.1 or later, and a C compiler.
No bugs have been reported.
Please report any bugs or feature requests to the author.
Goro Fuji (gfx) <gfuji(at)cpan.org>.
Copyright (c) 2009-20010, Goro Fuji (gfx). Some rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Sub-Attribute documentation | Contained in the Sub-Attribute distribution. |
package Sub::Attribute; use 5.008_001; use strict; our $VERSION = '0.05'; use XSLoader; XSLoader::load(__PACKAGE__, $VERSION); use parent qw(Exporter); our @EXPORT = qw(ATTR_SUB MODIFY_CODE_ATTRIBUTES); use attributes (); 1; __END__