This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add tests for mX?PUSH[inup] macros.
[perl5.git] / ext / attrs / attrs.pm
CommitLineData
77a005ab 1package attrs;
9426adcd 2use XSLoader ();
77a005ab 3
d6a466d7 4$VERSION = "1.01";
77a005ab
MB
5
6=head1 NAME
7
a98df962 8attrs - set/get attributes of a subroutine (deprecated)
77a005ab
MB
9
10=head1 SYNOPSIS
11
12 sub foo {
13 use attrs qw(locked method);
14 ...
15 }
16
17 @a = attrs::get(\&foo);
18
19=head1 DESCRIPTION
20
a98df962
GS
21NOTE: Use of this pragma is deprecated. Use the syntax
22
da2094fd 23 sub foo : locked method { }
a98df962
GS
24
25to declare attributes instead. See also L<attributes>.
26
27This pragma lets you set and get attributes for subroutines.
77a005ab
MB
28Setting attributes takes place at compile time; trying to set
29invalid attribute names causes a compile-time error. Calling
a98df962
GS
30C<attrs::get> on a subroutine reference or name returns its list
31of attribute names. Notice that C<attrs::get> is not exported.
77a005ab
MB
32Valid attributes are as follows.
33
bbc7dcd2 34=over 4
77a005ab
MB
35
36=item method
37
38Indicates that the invoking subroutine is a method.
39
40=item locked
41
42Setting this attribute is only meaningful when the subroutine or
43method is to be called by multiple threads. When set on a method
44subroutine (i.e. one marked with the B<method> attribute above),
45perl ensures that any invocation of it implicitly locks its first
46argument before execution. When set on a non-method subroutine,
47perl ensures that a lock is taken on the subroutine itself before
48execution. The semantics of the lock are exactly those of one
49explicitly taken with the C<lock> operator immediately after the
50subroutine is entered.
51
52=back
53
54=cut
55
9426adcd 56XSLoader::load 'attrs', $VERSION;
77a005ab
MB
57
581;