Sub::Attribute - Reliable subroutine attribute handlers


Sub-Attribute documentation Contained in the Sub-Attribute distribution.

Index


Code Index:

NAME

Top

Sub::Attribute - Reliable subroutine attribute handlers

VERSION

Top

This document describes Sub::Attribute version 0.05.

SYNOPSIS

Top

	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')

DESCRIPTION

Top

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.

INTERFACE

Top

The ATTR_SUB meta attribute

Defines a method as an subroutine attribute handler.

CONFIGURATION AND ENVIRONMENT

Top

$ENV{SUB_ATTRIBUTE_DEBUG}

If true, reports how attributes are applied, using warn() function.

DEPENDENCIES

Top

Perl 5.8.1 or later, and a C compiler.

BUGS

Top

No bugs have been reported.

Please report any bugs or feature requests to the author.

SEE ALSO

Top

attributes.

"Subroutine Attributes" in perlsub.

Attribute::Handlers.

AUTHOR

Top

Goro Fuji (gfx) <gfuji(at)cpan.org>.

LICENSE AND COPYRIGHT

Top


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__