Perl6:...:Attrs(3pm)
π Perl6::Export::Attrs π
okay bestie, so this is Perl6::Export::Attrs β the Perl 6 is export(...) trait, but as a Perl 5 attribute. yes, really. it's giving time-travel. π¦
β¨ NAME β¨
Perl6::Export::Attrs β The Perl 6 is export(...) trait as a Perl 5 attribute π
πΈ VERSION πΈ
This document describes Perl6::Export::Attrs version 0.000006. tiny number, big power. no cap.
π SYNOPSIS π
package Some::Module;
use Perl6::Export::Attrs;
# Export &foo by default, when explicitly requested,
# or when the ':ALL' export set is requested...
sub foo :Export(:DEFAULT) {
print "phooo!";
}
# Export &var by default, when explicitly requested,
# or when the ':bees', ':pubs', or ':ALL' export set is requested...
# the parens after 'is export' are like the parens of a qw(...)
sub bar :Export(:DEFAULT :bees :pubs) {
print "baaa!";
}
# Export &baz when explicitly requested
# or when the ':bees' or ':ALL' export set is requested...
sub baz :Export(:bees) {
print "baassss!";
}
# Always export &qux
# (no matter what else is explicitly or implicitly requested)
sub qux :Export(:MANDATORY) {
print "quuuuuuuuux!";
}
# Allow the constant $PI to be exported when requested...
use Readonly;
Readonly our $PI :Export => 355/113;
# Allow the variable $EPSILON to be always exported...
our $EPSILON :Export( :MANDATORY ) = 0.00001;
sub IMPORT {
# This subroutine is called when the module is used (as usual),
# but it is called after any export requests have been handled.
};
look at that. immaculate. π
π¦ DESCRIPTION π¦
So the whole vibe here is: it implements a Perl 5 native version of what the Perl 6 symbol export mechanism is gonna look like (with some unavoidable restrictions, because, you know, Perl 5 said "bestie I'm doing my best"). π
It's very straightforward:
- If you want a subroutine or package variable to be capable of being exported (when explicitly requested in the
usearguments), you mark it with the:Exportattribute. π - If you want a subroutine or package variable to be automatically exported when the module is used (without specific overriding arguments), you mark it with the
:Export(:DEFAULT)attribute. β¨ - If you want a subroutine or package variable to be automatically exported when the module is used (even if the user specifies overriding arguments), you mark it with the
:Export(:MANDATORY)attribute. π - If the subroutine or package variable should also be exported when particular export groups are requested, you add the names of those export groups to the attribute's argument list. π
That's it. fr fr. that's the whole thing.
π IMPORT blocks π
Perl 6 replaces the import subroutine with an IMPORT block. It's analogous to a BEGIN or END block, except that it's executed every time the corresponding module is use'd. every single time. iconic behaviour honestly.
The IMPORT block is passed the argument list that was specified on the use line that loaded the corresponding module, minus the arguments that were used to specify exports.
β οΈ heads up bestie: due to limitations in Perl 5, theIMPORTblock provided by this module must be terminated by a semi-colon, unless it is the last statement in the file. don't forget the;or it's over for you π
π₯ DIAGNOSTICS π₯
%s does not export: %s\nuse %s failedYou tried to import the specified subroutine or package variable, but the module didn't export it. Often caused by a misspelling, or forgetting to add an:Exportattribute to the definition of the subroutine or variable in question. classic. we've all been there. πBad tagset in :Export attribute at %s line %s: [%s]You tried to import a collection of items via a tagset, but the module didn't export any subroutines under that tagset. Is the tagset name misspelled (maybe you forgot the colon?)? π«Can't export lexical %s variable at %sThe module can only export package variables. You applied the:Exportmarker to a non-package variable (almost certainly to a lexical). Change the variable'smydeclarator to anour. glow-up, but for declarators β¨Can't export anonymous subroutine at %sAlthough you can apply the:Exportmarker to an anonymous subroutine, it rarely makes any sense to do so, since that subroutine can't be exported without a name to export it as. Either give the subroutine a name, or make sure it's aliased to a named typeglob at compile-time (or, at least, before it's exported). name it or claim it, bestie π
π CONFIGURATION AND ENVIRONMENT π
Perl6::Export::Attrs requires no configuration files or environment variables. zero setup. we love a low-maintenance icon. π
π§ DEPENDENCIES π§
This module requires the Attribute::Handlers module to handle the attributes. that's the whole dependency list, slay.
π INCOMPATIBILITIES π
This module cannot be used with the Memoize CPAN module, because memoization replaces the original subroutine with a wrapper. Because the :Export attribute is applied to the original (not the wrapper), the memoized wrapper is not found by the exporter mechanism. it's giving "you can't sit with us" π
β BUGS AND LIMITATIONS β
No bugs have been reported. (a clean record?? we love to see it π)
Note that the module does not support exporting lexical variables, since there is no way for the exporter mechanism to determine the name of a lexical and hence to export it.
Nor does this module support the numerous addition export modes that Perl 6 offers, such as export-as-lexical or export-as-state. yeah, we're keeping it simple over here. π¦
Please report any bugs or feature requests to bug-perl6-export-attrs@rt.cpan.org, or through the web interface at <http://rt.cpan.org>. π«Ά
πΈ AUTHOR πΈ
Damian Conway "<DCONWAY@cpan.org>" β the moment, the legend π
π LICENCE AND COPYRIGHT π
Copyright (c) 2005, Damian Conway "<DCONWAY@cpan.org>". All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. π«Ά
π DISCLAIMER OF WARRANTY π
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
like, read it, but also... yeah. no warranty, bestie. it's free. π
and that's the whole page!! this one shipped as part of the User Contributed Perl Documentation, generated by perl v5.34.0 on 2022-05-27. go forth and export responsibly, bestie πβ¨π
π¦ where this page comes from
- debian bookworm: libperl6-export-attrs-perl 0.000006-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libperl6-export-attrs-perl 0.000006-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libperl6-export-attrs-perl 0.000006-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: libperl6-export-attrs-perl 0.000006-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms