Debian Codegraph @

README

raw
1 NAME
2
3 Export::Attrs - The Perl 6 'is export(...)' trait as a Perl 5 attribute
4
5 VERSION
6
7 This document describes Export::Attrs version 0.000005
8
9 SYNOPSIS
10
11 package Some::Module;
12 use Export::Attrs;
13
14 # Export &foo by default, when explicitly requested,
15 # or when the ':ALL' export set is requested...
16
17 sub foo :Export(:DEFAULT) {
18 print "phooo!";
19 }
20
21
22 # Export &var by default, when explicitly requested,
23 # or when the ':bees', ':pubs', or ':ALL' export set is requested...
24 # the parens after 'is export' are like the parens of a qw(...)
25
26 sub bar :Export(:DEFAULT :bees :pubs) {
27 print "baaa!";
28 }
29
30
31 # Export &baz when explicitly requested
32 # or when the ':bees' or ':ALL' export set is requested...
33
34 sub baz :Export(:bees) {
35 print "baassss!";
36 }
37
38
39 # Always export &qux
40 # (no matter what else is explicitly or implicitly requested)
41
42 sub qux :Export(:MANDATORY) {
43 print "quuuuuuuuux!";
44 }
45
46
47 # Allow the constant $PI to be exported when requested...
48
49 use Readonly;
50 Readonly our $PI :Export => 355/113;
51
52
53 # Allow the variable $EPSILON to be always exported...
54
55 our $EPSILON :Export( :MANDATORY ) = 0.00001;
56
57
58 sub IMPORT {
59 # This subroutine is called when the module is used (as usual),
60 # but it is called after any export requests have been handled.
61 };
62
63 DESCRIPTION
64
65 NOTE: This module is a fork of Perl6::Export::Attrs created to restore
66 compatibility with Perl6::Export::Attrs version 0.0.3.
67
68 Implements a Perl 5 native version of what the Perl 6 symbol export
69 mechanism will look like (with some unavoidable restrictions).
70
71 It's very straightforward:
72
73 * If you want a subroutine or package variable to be capable of being
74 exported (when explicitly requested in the use arguments), you mark
75 it with the :Export attribute.
76
77 * If you want a subroutine or package variable to be automatically
78 exported when the module is used (without specific overriding
79 arguments), you mark it with the :Export(:DEFAULT) attribute.
80
81 * If you want a subroutine or package variable to be automatically
82 exported when the module is used (even if the user specifies
83 overriding arguments), you mark it with the :Export(:MANDATORY)
84 attribute.
85
86 * If the subroutine or package variable should also be exported when
87 particular export groups are requested, you add the names of those
88 export groups to the attribute's argument list.
89
90 That's it.
91
92 IMPORT blocks
93
94 Perl 6 replaces the import subroutine with an IMPORT block. It's
95 analogous to a BEGIN or END block, except that it's executed every time
96 the corresponding module is use'd.
97
98 The IMPORT block is passed the argument list that was specified on the
99 use line that loaded the corresponding module, minus the arguments that
100 were used to specify exports.
101
102 Note that, due to limitations in Perl 5, the IMPORT block provided by
103 this module must be terminated by a semi-colon, unless it is the last
104 statement in the file.
105
106 DIAGNOSTICS
107
108 %s does not export: %s\nuse %s failed
109
110 You tried to import the specified subroutine or package variable, but
111 the module didn't export it. Often caused by a misspelling, or
112 forgetting to add an :Export attribute to the definition of the
113 subroutine or variable in question.
114
115 Bad tagset in :Export attribute at %s line %s: [%s]
116
117 You tried to import a collection of items via a tagset, but the
118 module didn't export any subroutines under that tagset. Is the tagset
119 name misspelled (maybe you forgot the colon?).
120
121 Can't export lexical %s variable at %s
122
123 The module can only export package variables. You applied the :Export
124 marker to a non-package variable (almost certainly to a lexical).
125 Change the variable's my declarator to an our.
126
127 Can't export anonymous subroutine at %s
128
129 Although you can apply the :Export marker to an anonymous subroutine,
130 it rarely makes any sense to do so, since that subroutine can't be
131 exported without a name to export it as. Either give the subroutine a
132 name, or make sure it's aliased to a named typeglob at compile-time
133 (or, at least, before it's exported).
134
135 CONFIGURATION AND ENVIRONMENT
136
137 Export::Attrs requires no configuration files or environment variables.
138
139 DEPENDENCIES
140
141 This module requires the Attribute::Handlers module to handle the
142 attributes.
143
144 INCOMPATIBILITIES
145
146 This module cannot be used with the Memoize CPAN module, because
147 memoization replaces the original subroutine with a wrapper. Because
148 the :Export attribute is applied to the original (not the wrapper), the
149 memoized wrapper is not found by the exporter mechanism.
150
151 LIMITATIONS
152
153 Note that the module does not support exporting lexical variables,
154 since there is no way for the exporter mechanism to determine the name
155 of a lexical and hence to export it.
156
157 Nor does this module support the numerous addition export modes that
158 Perl 6 offers, such as export-as-lexical or export-as-state.
159
160 SUPPORT
161
162 Bugs / Feature Requests
163
164 Please report any bugs or feature requests through the issue tracker at
165 https://github.com/powerman/perl-Export-Attrs/issues. You will be
166 notified automatically of any progress on your issue.
167
168 Source Code
169
170 This is open source software. The code repository is available for
171 public review and contribution under the terms of the license. Feel
172 free to fork the repository and submit pull requests.
173
174 https://github.com/powerman/perl-Export-Attrs
175
176 git clone https://github.com/powerman/perl-Export-Attrs.git
177
178 Resources
179
180 * MetaCPAN Search
181
182 https://metacpan.org/search?q=Export-Attrs
183
184 * CPAN Ratings
185
186 http://cpanratings.perl.org/dist/Export-Attrs
187
188 * AnnoCPAN: Annotated CPAN documentation
189
190 http://annocpan.org/dist/Export-Attrs
191
192 * CPAN Testers Matrix
193
194 http://matrix.cpantesters.org/?dist=Export-Attrs
195
196 * CPANTS: A CPAN Testing Service (Kwalitee)
197
198 http://cpants.cpanauthors.org/dist/Export-Attrs
199
200 AUTHOR
201
202 Alex Efros <[email protected]>
203
204 Damian Conway <[email protected]>
205
206 COPYRIGHT AND LICENSE
207
208 This software is Copyright (c) 2016 by Alex Efros <[email protected]>.
209
210 Copyright (c) 2005,2015 Damian Conway <[email protected]>. All rights
211 reserved.
212
213 This module is free software; you can redistribute it and/or modify it
214 under the same terms as Perl itself.
215