|
NAMEPerl6::Export::Attrs - The Perl 6 'is export(...)' trait as a Perl 5 attributeVERSIONThis document describes Perl6::Export::Attrs version 0.000006SYNOPSISpackage 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. }; DESCRIPTIONImplements a Perl 5 native version of what the Perl 6 symbol export mechanism will look like (with some unavoidable restrictions).It's very straightforward:
That's it. "IMPORT" blocksPerl 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.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. Note that, due to limitations in Perl 5, the "IMPORT" block provided by this module must be terminated by a semi-colon, unless it is the last statement in the file. DIAGNOSTICS
CONFIGURATION AND ENVIRONMENTPerl6::Export::Attrs requires no configuration files or environment variables.DEPENDENCIESThis module requires the Attribute::Handlers module to handle the attributes.INCOMPATIBILITIESThis 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.BUGS AND LIMITATIONSNo bugs have been reported.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. 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>. AUTHORDamian Conway "<DCONWAY@cpan.org>"LICENCE AND COPYRIGHTCopyright (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 WARRANTYBECAUSE 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.
Visit the GSP FreeBSD Man Page Interface. |