2 package Moose::Autobox;
10 our $VERSION = '0.02';
14 package # hide from PAUSE
17 # this doesnt make sense, but
18 # I need to prevent Moose from
22 with 'Moose::Autobox::Scalar';
24 *does = \&Moose::Object::does;
26 package # hide from PAUSE
30 with 'Moose::Autobox::Array';
32 *does = \&Moose::Object::does;
34 package # hide from PAUSE
38 with 'Moose::Autobox::Hash';
40 *does = \&Moose::Object::does;
42 package # hide from PAUSE
46 with 'Moose::Autobox::Code';
48 *does = \&Moose::Object::does;
50 confess 'Could not create autobox packages because - ' . $@ if $@;
61 Moose::Autobox - Autoboxed for her pleasure
68 print 'Print squares from 1 to 10 : ';
69 print [ 1 .. 10 ]->map(sub { $_ * $_ })->join(', ');
75 This module is very very very very very very very experimental. It
76 makes use of a very experimental module (L<autobox>) and uses some
77 shiney new technology (L<Moose::Role>) to accomplish it's goals.
79 Use this at your own risk. If it breaks the lamp in the living room
80 and your mother yells at you, don't come complaining to me.
82 Also, as this is so experimental, it's API should not be considered
83 to be stable. It could very well change in radical ways.
87 Moose::Autobox provides an implementation of SCALAR, ARRAY, HASH
88 & CODE for use with L<autobox>. It does this using a hierarchy of
89 roles in a manner similar to what Perl 6 I<might> do. This module,
90 like L<Class::MOP> and L<Moose>, was inspired by my work on the
91 Perl 6 Object Space, and the 'core types' implemented there.
93 =head2 A quick word about autobox
95 The L<autobox> module provides the ability for calling 'methods'
96 on normal Perl values like Scalars, Arrays, Hashes and Code
97 references. This gives the illusion that Perl's types are first-class
98 objects. However, this is only an illusion, albeit a very nice one.
99 I created this module because L<autobox> itself does not actually
100 provide an implementation for the Perl types but instead only provides
101 the 'hooks' for others to add implementation too.
103 =head2 Is this for real? or just play?
105 My intent is to try and make this module as production worthy as
106 possible. This may or may not be possible, depending on how well
107 L<autobox> works out. At this point, I have high hopes for things
108 but only time (and more tests and code) will tell.
112 This is a rough diagram of the roles involved to get our 4
113 autoboxed types (SCALAR, ARRAY, HASH & CODE).
115 +------------------------+-------------------------------+
116 | Identity | Behavioral |
117 +------------------------+-------------------------------+
121 | Scalar* <-|- String, Number <--+ |
123 | Array* <-|- List <------------+ |
127 +------------------------+-------------------------------+
129 * indicates actual autoboxed types
143 - String, Number & List are currently the only 'Value's.
145 - Indexed is pretty much an interface, we probably will
146 need more of these (see Smalltalk Collection Trait
151 All complex software has bugs lurking in it, and this module is no
152 exception. If you find a bug please either email me, or add the bug
157 Stevan Little E<lt>stevan@iinteractive.comE<gt>
159 =head1 COPYRIGHT AND LICENSE
161 Copyright 2006 by Infinity Interactive, Inc.
163 L<http://www.iinteractive.com>
165 This library is free software; you can redistribute it and/or modify
166 it under the same terms as Perl itself.