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