foo
[gitmo/Moose-Autobox.git] / lib / Moose / Autobox.pm
CommitLineData
5f654d8e 1
2package Moose::Autobox;
3
4use strict;
5use warnings;
6
31d40d73 7use Carp qw(confess);
5f654d8e 8use Scalar::Util ();
9
2f6b31a1 10our $VERSION = '0.02';
5f654d8e 11
8937074a 12sub import {
13 eval q|
2f6b31a1 14package # hide from PAUSE
15 SCALAR;
31d40d73 16# NOTE:
17# this doesnt make sense, but
18# I need to prevent Moose from
19# assiging to @ISA
5272f13f 20use base 'UNIVERSAL';
5f654d8e 21use Moose;
22with 'Moose::Autobox::Scalar';
23
31d40d73 24*does = \&Moose::Object::does;
25
2f6b31a1 26package # hide from PAUSE
27 ARRAY;
5272f13f 28use base 'UNIVERSAL';
5f654d8e 29use Moose;
30with 'Moose::Autobox::Array';
31
31d40d73 32*does = \&Moose::Object::does;
33
2f6b31a1 34package # hide from PAUSE
35 HASH;
5272f13f 36use base 'UNIVERSAL';
5f654d8e 37use Moose;
38with 'Moose::Autobox::Hash';
39
31d40d73 40*does = \&Moose::Object::does;
41
2f6b31a1 42package # hide from PAUSE
43 CODE;
5272f13f 44use base 'UNIVERSAL';
5f654d8e 45use Moose;
31d40d73 46with 'Moose::Autobox::Code';
47
48*does = \&Moose::Object::does;
8937074a 49 |;
50 confess 'Could not create autobox packages because - ' . $@ if $@;
51}
5f654d8e 52
531;
54
55__END__
56
57=pod
58
59=head1 NAME
60
8937074a 61Moose::Autobox - Autoboxed for her pleasure
5f654d8e 62
63=head1 SYNOPOSIS
64
39894c95 65 use Moose::Autobox;
66 use autobox;
31d40d73 67
8937074a 68 print 'Print squares from 1 to 10 : ';
69 print [ 1 .. 10 ]->map(sub { $_ * $_ })->join(', ');
70
71=head1 CAVEAT
72
73First, a warning.
74
75This module is very very very very very very very experimental. It
76makes use of a very experimental module (L<autobox>) and uses some
77shiney new technology (L<Moose::Role>) to accomplish it's goals.
78
79Use this at your own risk. If it breaks the lamp in the living room
80and your mother yells at you, don't come complaining to me.
39894c95 81
1972aa1b 82Also, as this is so experimental, it's API should not be considered
83to be stable. It could very well change in radical ways.
84
5f654d8e 85=head1 DESCRIPTION
86
8937074a 87Moose::Autobox provides an implementation of SCALAR, ARRAY, HASH
88& CODE for use with L<autobox>. It does this using a hierarchy of
89roles in a manner similar to what Perl 6 I<might> do. This module,
90like L<Class::MOP> and L<Moose>, was inspired by my work on the
91Perl 6 Object Space, and the 'core types' implemented there.
92
93=head2 A quick word about autobox
94
95The L<autobox> module provides the ability for calling 'methods'
96on normal Perl values like Scalars, Arrays, Hashes and Code
97references. This gives the illusion that Perl's types are first-class
98objects. However, this is only an illusion, albeit a very nice one.
99I created this module because L<autobox> itself does not actually
100provide an implementation for the Perl types but instead only provides
101the 'hooks' for others to add implementation too.
102
103=head2 Is this for real? or just play?
104
105My intent is to try and make this module as production worthy as
106possible. This may or may not be possible, depending on how well
107L<autobox> works out. At this point, I have high hopes for things
108but only time (and more tests and code) will tell.
109
39894c95 110=head1 ROLES
8937074a 111
112This is a rough diagram of the roles involved to get our 4
113autoboxed types (SCALAR, ARRAY, HASH & CODE).
260cc81f 114
115 +------------------------+-------------------------------+
116 | Identity | Behavioral |
117 +------------------------+-------------------------------+
118 | Item | |
119 | Undef | |
120 | Defined | |
121 | Scalar* <-|- String, Number <--+ |
122 | Ref | |-- Value |
123 | Array* <-|- List <------------+ |
124 | Hash* | |
125 | Code* | |
126 | | |
127 +------------------------+-------------------------------+
128
39894c95 129 * indicates actual autoboxed types
1972aa1b 130
131=head1 TODO
132
133=over 4
134
135=item More docs
136
137=item More tests
138
139=back
31d40d73 140
141=head1 NOTES
142
8937074a 143 - String, Number & List are currently the only 'Value's.
31d40d73 144
145 - Indexed is pretty much an interface, we probably will
146 need more of these (see Smalltalk Collection Trait
147 Refactoring)
148
5f654d8e 149=head1 BUGS
150
151All complex software has bugs lurking in it, and this module is no
152exception. If you find a bug please either email me, or add the bug
153to cpan-RT.
154
155=head1 AUTHOR
156
157Stevan Little E<lt>stevan@iinteractive.comE<gt>
158
159=head1 COPYRIGHT AND LICENSE
160
161Copyright 2006 by Infinity Interactive, Inc.
162
163L<http://www.iinteractive.com>
164
165This library is free software; you can redistribute it and/or modify
166it under the same terms as Perl itself.
167
5f654d8e 168=cut