Perl6::Export(3pm)
π Perl6::Export π
okay bestie, so this page is Perl6::Export(3pm), and it lives in the User Contributed Perl Documentation section. it's a whole thing, and it's giving very "I'm implementing the future" energy. let's get into it π«Ά
β¨ NAME β¨
Perl6::Export β it implements the Perl 6 is export(...) trait, no cap π
πΈ SYNOPSIS πΈ
okay so here's the vibe, in code, verbatim, don't touch a single character:
# Perl 5 code...
package Some::Module;
use Perl6::Export;
# Export &foo by default, when explicitly requested,
# or when the ':ALL' export set is requested...
sub foo is export(:DEFAULT) {
print "phooo!";
}
# Export &bar 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 is export(:DEFAULT :bees :pubs) {
print "baaa!";
}
# Export &baz when explicitly requested
# or when the ':bees' or ':ALL' export set is requested...
sub baz is export(:bees) {
print "baassss!";
}
# Always export &qux
# (no matter what else is explicitly or implicitly requested)
sub qux is export(:MANDATORY) {
print "quuuuuuuuux!";
}
IMPORT {
# This block is called when the module is used (as usual),
# but it is called after any export requests have been handled.
# Those requests will have been stripped from its @_ argument list
}
like, that's it. that's the whole personality. <pink>gorg</pink> π
π DESCRIPTION π
so this module implements what the author hopes the Perl 6 symbol export mechanism might look like. fingers crossed bestie π€β¨
It's very straightforward: (authors words, not mine, but honestly? accurate.)
- If you want a subroutine to be capable of being exported (when explicitly requested in the
usearguments), you mark it with theis exporttrait. π - If you want a subroutine to be automatically exported when the module is used (without specific overriding arguments), you mark it with the
is export(:DEFAULT)trait. π« - If you want a subroutine to be automatically exported when the module is used (even if the user specifies overriding arguments), you mark it with the
is export(:MANDATORY)trait. π - If the subroutine should also be exported when particular export groups are requested, you add the names of those export groups to the trait's argument list. π¦
That's it. periodt. π
π "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. like, every single time. main character behavior honestly.
Perl6::Export honours either the Perl5-ish:
sub import {...}
or the equivalent Perl6-ish:
IMPORT {...}
In either case the subroutine/block is passed the argument list that was specified on the use line that loaded the corresponding module. However, any export specifications (names of subroutines or tagsets to be exported) will have already been removed from that argument list before import/IMPORT receives it. so like, it got a little haircut first πββοΈ
β οΈ WARNING β οΈ
The syntax and semantics of Perl 6 is still being finalized and consequently is at any time subject to change. That means the same caveat applies to this module.
bestie. listen. this is the "everything is subject to change" zone. nothing is stable. the ground is lava. proceed with vibes and backups. π
π§ DEPENDENCIES π§
Requires Filter::Simple β that's the whole list, she's low maintenance fr fr
π AUTHOR π
Damian Conway (damian@conway.org) β icon, legend, the moment π
π BUGS AND IRRITATIONS π
Does not yet handle the export of variables. The author personally believes this is a feature, rather than a bug. (and honestly? slay, king.)
Comments, suggestions, and patches welcome. π«Ά send them in, we're not gatekeeping.
β COPYRIGHT β
Copyright (c) 2003, Damian Conway. All Rights Reserved.
This module is free software. It may be used, redistributed
and/or modified under the same terms as Perl itself.
and that's the whole page bestie π this was perl v5.36.0, dated 2022-10-13, and it's the Perl6::Export(3pm) manual that lives over in User Contributed Perl Documentation. go forth and is export(:DEFAULT) responsibly π
β¨πΈ
π¦ where this page comes from
- ubuntu noble: libperl6-export-perl 0.009-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libperl6-export-perl 0.009-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libperl6-export-perl 0.009-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms