1Moose::Autobox(3) User Contributed Perl Documentation Moose::Autobox(3)
2
3
4
6 Moose::Autobox - Autoboxed wrappers for Native Perl datatypes
7
9 version 0.16
10
12 use Moose::Autobox;
13
14 print 'Print squares from 1 to 10 : ';
15 print [ 1 .. 10 ]->map(sub { $_ * $_ })->join(', ');
16
18 Moose::Autobox provides an implementation of SCALAR, ARRAY, HASH & CODE
19 for use with autobox. It does this using a hierarchy of roles in a
20 manner similar to what Perl 6 might do. This module, like Class::MOP
21 and Moose, was inspired by my work on the Perl 6 Object Space, and the
22 'core types' implemented there.
23
24 A quick word about autobox
25 The autobox module provides the ability for calling 'methods' on normal
26 Perl values like Scalars, Arrays, Hashes and Code references. This
27 gives the illusion that Perl's types are first-class objects. However,
28 this is only an illusion, albeit a very nice one. I created this
29 module because autobox itself does not actually provide an
30 implementation for the Perl types but instead only provides the 'hooks'
31 for others to add implementation too.
32
33 Is this for real? or just play?
34 Several people are using this module in serious applications and it
35 seems to be quite stable. The underlying technologies of autobox and
36 Moose::Role are also considered stable. There is some performance hit,
37 but as I am fond of saying, nothing in life is free. Note that this
38 hit only applies to the use of methods on native Perl values, not the
39 mere act of loading this module in your namespace.
40
41 If you have any questions regarding this module, either email me, or
42 stop by #moose on irc.perl.org and ask around.
43
44 Adding additional methods
45 Moose::Autobox asks autobox to use the Moose::Autobox::* namespace
46 prefix so as to avoid stepping on the toes of other autobox modules.
47 This means that if you want to add methods to a particular perl type
48 (i.e. - monkeypatch), then you must do this:
49
50 sub Moose::Autobox::SCALAR::bar { 42 }
51
52 instead of this:
53
54 sub SCALAR::bar { 42 }
55
56 as you would with vanilla autobox.
57
59 "mixin_additional_role ($type, $role)"
60 This will mixin an additional $role into a certain $type. The types
61 can be SCALAR, ARRAY, HASH or CODE.
62
63 This can be used to add additional methods to the types, see the
64 examples/units/ directory for some examples.
65
67 More docs
68 More tests
69
71 Bugs may be submitted through the RT bug tracker
72 <https://rt.cpan.org/Public/Dist/Display.html?Name=Moose-Autobox> (or
73 bug-Moose-Autobox@rt.cpan.org <mailto:bug-Moose-Autobox@rt.cpan.org>).
74
75 There is also a mailing list available for users of this distribution,
76 at <http://lists.perl.org/list/moose.html>.
77
78 There is also an irc channel available for users of this distribution,
79 at "#moose" on "irc.perl.org" <irc://irc.perl.org/#moose>.
80
82 Stevan Little <stevan.little@iinteractive.com>
83
85 · Ricardo Signes <rjbs@cpan.org>
86
87 · Karen Etheridge <ether@cpan.org>
88
89 · Anders Nor Berle <berle@cpan.org>
90
91 · Matt S Trout <mst@shadowcat.co.uk>
92
93 · Steffen Schwigon <ss5@renormalist.net>
94
95 · Michael Swearingen <mswearingen@gmail.com>
96
97 · Florian Ragwitz <rafl@debian.org>
98
99 · Jonathan Rockway <jon@jrock.us>
100
101 · Shawn M Moore <sartak@gmail.com>
102
103 · Todd Hepler <thepler@employees.org>
104
105 · David Steinbrunner <dsteinbrunner@pobox.com>
106
107 · Mike Whitaker <mike@altrion.org>
108
109 · Nigel Gregoire <nigelgregoire@gmail.com>
110
112 This software is copyright (c) 2006 by Infinity Interactive, Inc.
113
114 This is free software; you can redistribute it and/or modify it under
115 the same terms as the Perl 5 programming language system itself.
116
117
118
119perl v5.28.0 2016-05-03 Moose::Autobox(3)