1Exporter::Tiny::Manual:U:sEetrc(C3o)ntributed Perl DocumEexnptoarttieorn::Tiny::Manual::Etc(3)
2
3
4
6 Exporter::Tiny::Manual::Etc - odds and ends
7
9 Utility Functions
10 Exporter::Tiny is itself an exporter!
11
12 These functions are really for internal use, but can be exported if you
13 need them:
14
15 "mkopt(\@array)"
16 Similar to "mkopt" from Data::OptList. It doesn't support all the
17 fancy options that Data::OptList does ("moniker", "require_unique",
18 "must_be" and "name_test") but runs about 50% faster.
19
20 "mkopt_hash(\@array)"
21 Similar to "mkopt_hash" from Data::OptList. See also "mkopt".
22
23 History
24 Type::Library had a bunch of custom exporting code which poked coderefs
25 into its caller's stash. It needed this to be something more powerful
26 than most exporters so that it could switch between exporting Moose,
27 Mouse and Moo-compatible objects on request. Sub::Exporter would have
28 been capable, but had too many dependencies for the Type::Tiny project.
29
30 Meanwhile Type::Utils, Types::TypeTiny and Test::TypeTiny each used the
31 venerable Exporter.pm. However, this meant they were unable to use the
32 features like Sub::Exporter-style function renaming which I'd built
33 into Type::Library:
34
35 ## import "Str" but rename it to "String".
36 use Types::Standard "Str" => { -as => "String" };
37
38 And so I decided to factor out code that could be shared by all Type-
39 Tiny's exporters into a single place: Exporter::TypeTiny.
40
41 As of version 0.026, Exporter::TypeTiny was also made available as
42 Exporter::Tiny, distributed independently on CPAN. CHOCOLATEBOY had
43 convinced me that it was mature enough to live a life of its own.
44
45 As of version 0.030, Type-Tiny depends on Exporter::Tiny and
46 Exporter::TypeTiny is being phased out.
47
48 Obligatory Exporter Comparison
49 Exporting is unlikely to be your application's performance bottleneck,
50 but nonetheless here are some comparisons.
51
52 Comparative sizes according to Devel::SizeMe:
53
54 Exporter 217.1Kb
55 Sub::Exporter::Progressive 263.2Kb
56 Exporter::Tiny 267.7Kb
57 Exporter + Exporter::Heavy 281.5Kb
58 Exporter::Renaming 406.2Kb
59 Sub::Exporter 701.0Kb
60
61 Performance exporting a single sub:
62
63 Rate SubExp ExpTiny SubExpProg ExpPM
64 SubExp 2489/s -- -56% -85% -88%
65 ExpTiny 5635/s 126% -- -67% -72%
66 SubExpProg 16905/s 579% 200% -- -16%
67 ExpPM 20097/s 707% 257% 19% --
68
69 (Exporter::Renaming globally changes the behaviour of Exporter.pm, so
70 could not be included in the same benchmarks.)
71
72 (Non-Core) Dependencies:
73
74 Exporter -1
75 Exporter::Renaming 0
76 Exporter::Tiny 0
77 Sub::Exporter::Progressive 0
78 Sub::Exporter 3
79
80 Features:
81
82 ExpPM ExpTiny SubExp SubExpProg
83 Can export code symbols............. Yes Yes Yes Yes
84 Can export non-code symbols......... Yes Yes
85 Groups/tags......................... Yes Yes Yes Yes
86 Export by regexp.................... Yes Yes
87 Bang prefix......................... Yes Yes
88 Allows renaming of subs............. Yes Yes Maybe
89 Install code into scalar refs....... Yes Yes Maybe
90 Can be passed an "into" parameter... Yes Yes Maybe
91 Can be passed an "installer" sub.... Yes Yes Maybe
92 Config avoids package variables..... Yes
93 Supports generators................. Yes Yes
94 Sane API for generators............. Yes Yes
95 Unimport............................ Yes
96
97 (Certain Sub::Exporter::Progressive features are only available if
98 Sub::Exporter is installed.)
99
101 Exporter::Shiny, Exporter::Tiny.
102
104 Toby Inkster <tobyink@cpan.org>.
105
107 This software is copyright (c) 2013-2014, 2017 by Toby Inkster.
108
109 This is free software; you can redistribute it and/or modify it under
110 the same terms as the Perl 5 programming language system itself.
111
113 THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
114 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
115 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
116
117
118
119perl v5.36.0 2022-11-21 Exporter::Tiny::Manual::Etc(3)