NAME
Exporter::Tiny::Manual::Etc - odds and ends
DESCRIPTION
Utility Functions
Exporter::Tiny is itself an exporter!
These functions are really for internal use, but can be exported if you need them:
- mkopt(\@array)
-
Similar to
"mkopt"from Data::OptList. It doesn't support all the fancy options that Data::OptList does ("moniker","require_unique","must_be"and"name_test") but runs about 50% faster.
- mkopt_hash(\@array)
-
Similar to
"mkopt_hash"from Data::OptList. See also"mkopt".
History
Type::Library had a bunch of custom exporting code which poked coderefs into its caller's stash. It needed this to be something more powerful than most exporters so that it could switch between exporting Moose, Mouse and Moo-compatible objects on request. Sub::Exporter would have been capable, but had too many dependencies for the Type::Tiny project.
Meanwhile Type::Utils, Types::TypeTiny and Test::TypeTiny each used the venerable Exporter.pm. However, this meant they were unable to use the features like Sub::Exporter-style function renaming which I'd built into Type::Library:
## import "Str" but rename it to "String".use Types::Standard "Str" => { -as => "String" };
And so I decided to factor out code that could be shared by all Type-Tiny's exporters into a single place: Exporter::TypeTiny.
As of version 0.026, Exporter::TypeTiny was also made available as Exporter::Tiny, distributed independently on CPAN. CHOCOLATEBOY had convinced me that it was mature enough to live a life of its own.
As of version 0.030, Type-Tiny depends on Exporter::Tiny and Exporter::TypeTiny is being phased out.
Obligatory Exporter Comparison
Exporting is unlikely to be your application's performance bottleneck, but nonetheless here are some comparisons.
Comparative sizes according to Devel::SizeMe:
Exporter 217.1KbSub::Exporter::Progressive 263.2KbExporter::Tiny 267.7KbExporter + Exporter::Heavy 281.5KbExporter::Renaming 406.2KbSub::Exporter 701.0Kb
Performance exporting a single sub:
Rate SubExp ExpTiny SubExpProg ExpPMSubExp 2489/s -- -56% -85% -88%ExpTiny 5635/s 126% -- -67% -72%SubExpProg 16905/s 579% 200% -- -16%ExpPM 20097/s 707% 257% 19% --
(Exporter::Renaming globally changes the behaviour of Exporter.pm, so could not be included in the same benchmarks.)
(Non-Core) Dependencies:
Exporter -1Exporter::Renaming 0Exporter::Tiny 0Sub::Exporter::Progressive 0Sub::Exporter 3
Features:
ExpPM ExpTiny SubExp SubExpProgCan export code symbols............. Yes Yes Yes YesCan export non-code symbols......... Yes YesGroups/tags......................... Yes Yes Yes YesExport by regexp.................... Yes YesBang prefix......................... Yes YesAllows renaming of subs............. Yes Yes MaybeInstall code into scalar refs....... Yes Yes MaybeCan be passed an "into" parameter... Yes Yes MaybeCan be passed an "installer" sub.... Yes Yes MaybeConfig avoids package variables..... YesSupports generators................. Yes YesSane API for generators............. Yes YesUnimport............................ Yes
(Certain Sub::Exporter::Progressive features are only available if Sub::Exporter is installed.)
SEE ALSO
<https://exportertiny.github.io/>.
Exporter::Shiny, Exporter::Tiny.
AUTHOR
Toby Inkster <[email protected]>.
COPYRIGHT AND LICENCE
This software is copyright (c) 2013-2014, 2017, 2022-2025 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.