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
7dad2765 10our $VERSION = '0.03';
11
12use base 'autobox';
13
8937074a 14sub import {
7dad2765 15 (shift)->SUPER::import(
16 DEFAULT => 'Moose::Autobox::',
17 UNDEF => 'Moose::Autobox::Undef',
18 );
19}
20
21package Moose::Autobox::SCALAR;
31d40d73 22# NOTE:
23# this doesnt make sense, but
24# I need to prevent Moose from
25# assiging to @ISA
5272f13f 26use base 'UNIVERSAL';
5f654d8e 27use Moose;
28with 'Moose::Autobox::Scalar';
29
31d40d73 30*does = \&Moose::Object::does;
31
7dad2765 32package Moose::Autobox::ARRAY;
5272f13f 33use base 'UNIVERSAL';
5f654d8e 34use Moose;
35with 'Moose::Autobox::Array';
36
31d40d73 37*does = \&Moose::Object::does;
38
7dad2765 39package Moose::Autobox::HASH;
5272f13f 40use base 'UNIVERSAL';
5f654d8e 41use Moose;
42with 'Moose::Autobox::Hash';
43
31d40d73 44*does = \&Moose::Object::does;
45
7dad2765 46package Moose::Autobox::CODE;
5272f13f 47use base 'UNIVERSAL';
5f654d8e 48use Moose;
31d40d73 49with 'Moose::Autobox::Code';
50
7dad2765 51*does = \&Moose::Object::does;
52
531;
54
55__END__
56
57=pod
58
59=head1 NAME
60
61Moose::Autobox - Autoboxed for her pleasure
62
63=head1 SYNOPOSIS
64
65 use Moose::Autobox;
66 use autobox;
67
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.
81
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
85=head1 DESCRIPTION
86
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
110=head1 ROLES
111
112This is a rough diagram of the roles involved to get our 4
113autoboxed types (SCALAR, ARRAY, HASH & CODE).
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
129 * indicates actual autoboxed types
130
131=head1 TODO
132
133=over 4
134
135=item More docs
136
137=item More tests
138
139=back
140
141=head1 NOTES
142
143 - String, Number & List are currently the only 'Value's.
144
145 - Indexed is pretty much an interface, we probably will
146 need more of these (see Smalltalk Collection Trait
147 Refactoring)
148
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
168=cut
169
170package Moose::Autobox;
171
172use strict;
173use warnings;
174
175use Carp qw(confess);
176use Scalar::Util ();
177
178our $VERSION = '0.02';
179
180package Moose::Autobox::SCALAR;
181# NOTE:
182# this doesnt make sense, but
183# I need to prevent Moose from
184# assiging to @ISA
185use base 'UNIVERSAL';
186use Moose;
187with 'Moose::Autobox::Scalar';
188
189*does = \&Moose::Object::does;
190
191package Moose::Autobox::ARRAY;
192use base 'UNIVERSAL';
193use Moose;
194with 'Moose::Autobox::Array';
195
31d40d73 196*does = \&Moose::Object::does;
5f654d8e 197
7dad2765 198package Moose::Autobox::HASH;
199use base 'UNIVERSAL';
200use Moose;
201with 'Moose::Autobox::Hash';
202
203*does = \&Moose::Object::does;
204
205package Moose::Autobox::CODE;
206use base 'UNIVERSAL';
207use Moose;
208with 'Moose::Autobox::Code';
209
210*does = \&Moose::Object::does;
211
2121;
213
214__END__
215
216=pod
217
218=head1 NAME
219
220Moose::Autobox - Autoboxed for her pleasure
221
222=head1 SYNOPOSIS
223
224 use Moose::Autobox;
225 use autobox;
226
227 print 'Print squares from 1 to 10 : ';
228 print [ 1 .. 10 ]->map(sub { $_ * $_ })->join(', ');
229
230=head1 CAVEAT
231
232First, a warning.
233
234This module is very very very very very very very experimental. It
235makes use of a very experimental module (L<autobox>) and uses some
236shiney new technology (L<Moose::Role>) to accomplish it's goals.
237
238Use this at your own risk. If it breaks the lamp in the living room
239and your mother yells at you, don't come complaining to me.
240
241Also, as this is so experimental, it's API should not be considered
242to be stable. It could very well change in radical ways.
243
244=head1 DESCRIPTION
245
246Moose::Autobox provides an implementation of SCALAR, ARRAY, HASH
247& CODE for use with L<autobox>. It does this using a hierarchy of
248roles in a manner similar to what Perl 6 I<might> do. This module,
249like L<Class::MOP> and L<Moose>, was inspired by my work on the
250Perl 6 Object Space, and the 'core types' implemented there.
251
252=head2 A quick word about autobox
253
254The L<autobox> module provides the ability for calling 'methods'
255on normal Perl values like Scalars, Arrays, Hashes and Code
256references. This gives the illusion that Perl's types are first-class
257objects. However, this is only an illusion, albeit a very nice one.
258I created this module because L<autobox> itself does not actually
259provide an implementation for the Perl types but instead only provides
260the 'hooks' for others to add implementation too.
261
262=head2 Is this for real? or just play?
263
264My intent is to try and make this module as production worthy as
265possible. This may or may not be possible, depending on how well
266L<autobox> works out. At this point, I have high hopes for things
267but only time (and more tests and code) will tell.
268
269=head1 ROLES
270
271This is a rough diagram of the roles involved to get our 4
272autoboxed types (SCALAR, ARRAY, HASH & CODE).
273
274 +------------------------+-------------------------------+
275 | Identity | Behavioral |
276 +------------------------+-------------------------------+
277 | Item | |
278 | Undef | |
279 | Defined | |
280 | Scalar* <-|- String, Number <--+ |
281 | Ref | |-- Value |
282 | Array* <-|- List <------------+ |
283 | Hash* | |
284 | Code* | |
285 | | |
286 +------------------------+-------------------------------+
287
288 * indicates actual autoboxed types
289
290=head1 TODO
291
292=over 4
293
294=item More docs
295
296=item More tests
297
298=back
299
300=head1 NOTES
301
302 - String, Number & List are currently the only 'Value's.
303
304 - Indexed is pretty much an interface, we probably will
305 need more of these (see Smalltalk Collection Trait
306 Refactoring)
307
308=head1 BUGS
309
310All complex software has bugs lurking in it, and this module is no
311exception. If you find a bug please either email me, or add the bug
312to cpan-RT.
313
314=head1 AUTHOR
315
316Stevan Little E<lt>stevan@iinteractive.comE<gt>
317
318=head1 COPYRIGHT AND LICENSE
319
320Copyright 2006 by Infinity Interactive, Inc.
321
322L<http://www.iinteractive.com>
323
324This library is free software; you can redistribute it and/or modify
325it under the same terms as Perl itself.
326
327=cut
328
329package Moose::Autobox;
330
331use strict;
332use warnings;
333
334use Carp qw(confess);
335use Scalar::Util ();
336
337our $VERSION = '0.02';
338
339package Moose::Autobox::SCALAR;
340# NOTE:
341# this doesnt make sense, but
342# I need to prevent Moose from
343# assiging to @ISA
344use base 'UNIVERSAL';
345use Moose;
346with 'Moose::Autobox::Scalar';
347
348*does = \&Moose::Object::does;
349
350package Moose::Autobox::ARRAY;
351use base 'UNIVERSAL';
352use Moose;
353with 'Moose::Autobox::Array';
354
355*does = \&Moose::Object::does;
356
357package Moose::Autobox::HASH;
358use base 'UNIVERSAL';
359use Moose;
360with 'Moose::Autobox::Hash';
361
362*does = \&Moose::Object::does;
363
364package Moose::Autobox::CODE;
365use base 'UNIVERSAL';
366use Moose;
367with 'Moose::Autobox::Code';
368
369*does = \&Moose::Object::does;
370
3711;
372
373__END__
374
375=pod
376
377=head1 NAME
378
379Moose::Autobox - Autoboxed for her pleasure
380
381=head1 SYNOPOSIS
382
383 use Moose::Autobox;
384 use autobox;
385
386 print 'Print squares from 1 to 10 : ';
387 print [ 1 .. 10 ]->map(sub { $_ * $_ })->join(', ');
388
389=head1 CAVEAT
390
391First, a warning.
392
393This module is very very very very very very very experimental. It
394makes use of a very experimental module (L<autobox>) and uses some
395shiney new technology (L<Moose::Role>) to accomplish it's goals.
396
397Use this at your own risk. If it breaks the lamp in the living room
398and your mother yells at you, don't come complaining to me.
399
400Also, as this is so experimental, it's API should not be considered
401to be stable. It could very well change in radical ways.
402
403=head1 DESCRIPTION
404
405Moose::Autobox provides an implementation of SCALAR, ARRAY, HASH
406& CODE for use with L<autobox>. It does this using a hierarchy of
407roles in a manner similar to what Perl 6 I<might> do. This module,
408like L<Class::MOP> and L<Moose>, was inspired by my work on the
409Perl 6 Object Space, and the 'core types' implemented there.
410
411=head2 A quick word about autobox
412
413The L<autobox> module provides the ability for calling 'methods'
414on normal Perl values like Scalars, Arrays, Hashes and Code
415references. This gives the illusion that Perl's types are first-class
416objects. However, this is only an illusion, albeit a very nice one.
417I created this module because L<autobox> itself does not actually
418provide an implementation for the Perl types but instead only provides
419the 'hooks' for others to add implementation too.
420
421=head2 Is this for real? or just play?
422
423My intent is to try and make this module as production worthy as
424possible. This may or may not be possible, depending on how well
425L<autobox> works out. At this point, I have high hopes for things
426but only time (and more tests and code) will tell.
427
428=head1 ROLES
429
430This is a rough diagram of the roles involved to get our 4
431autoboxed types (SCALAR, ARRAY, HASH & CODE).
432
433 +------------------------+-------------------------------+
434 | Identity | Behavioral |
435 +------------------------+-------------------------------+
436 | Item | |
437 | Undef | |
438 | Defined | |
439 | Scalar* <-|- String, Number <--+ |
440 | Ref | |-- Value |
441 | Array* <-|- List <------------+ |
442 | Hash* | |
443 | Code* | |
444 | | |
445 +------------------------+-------------------------------+
446
447 * indicates actual autoboxed types
448
449=head1 TODO
450
451=over 4
452
453=item More docs
454
455=item More tests
456
457=back
458
459=head1 NOTES
460
461 - String, Number & List are currently the only 'Value's.
462
463 - Indexed is pretty much an interface, we probably will
464 need more of these (see Smalltalk Collection Trait
465 Refactoring)
466
467=head1 BUGS
468
469All complex software has bugs lurking in it, and this module is no
470exception. If you find a bug please either email me, or add the bug
471to cpan-RT.
472
473=head1 AUTHOR
474
475Stevan Little E<lt>stevan@iinteractive.comE<gt>
476
477=head1 COPYRIGHT AND LICENSE
478
479Copyright 2006 by Infinity Interactive, Inc.
480
481L<http://www.iinteractive.com>
482
483This library is free software; you can redistribute it and/or modify
484it under the same terms as Perl itself.
485
486=cut
487
488package Moose::Autobox;
489
490use strict;
491use warnings;
492
493use Carp qw(confess);
494use Scalar::Util ();
495
496our $VERSION = '0.02';
497
498package Moose::Autobox::SCALAR;
499# NOTE:
500# this doesnt make sense, but
501# I need to prevent Moose from
502# assiging to @ISA
503use base 'UNIVERSAL';
504use Moose;
505with 'Moose::Autobox::Scalar';
506
507*does = \&Moose::Object::does;
508
509package Moose::Autobox::ARRAY;
510use base 'UNIVERSAL';
511use Moose;
512with 'Moose::Autobox::Array';
513
514*does = \&Moose::Object::does;
515
516package Moose::Autobox::HASH;
517use base 'UNIVERSAL';
518use Moose;
519with 'Moose::Autobox::Hash';
520
521*does = \&Moose::Object::does;
522
523package Moose::Autobox::CODE;
524use base 'UNIVERSAL';
525use Moose;
526with 'Moose::Autobox::Code';
527
528*does = \&Moose::Object::does;
529
5301;
531
532__END__
533
534=pod
535
536=head1 NAME
537
538Moose::Autobox - Autoboxed for her pleasure
539
540=head1 SYNOPOSIS
541
542 use Moose::Autobox;
543 use autobox;
544
545 print 'Print squares from 1 to 10 : ';
546 print [ 1 .. 10 ]->map(sub { $_ * $_ })->join(', ');
547
548=head1 CAVEAT
549
550First, a warning.
551
552This module is very very very very very very very experimental. It
553makes use of a very experimental module (L<autobox>) and uses some
554shiney new technology (L<Moose::Role>) to accomplish it's goals.
555
556Use this at your own risk. If it breaks the lamp in the living room
557and your mother yells at you, don't come complaining to me.
558
559Also, as this is so experimental, it's API should not be considered
560to be stable. It could very well change in radical ways.
561
562=head1 DESCRIPTION
563
564Moose::Autobox provides an implementation of SCALAR, ARRAY, HASH
565& CODE for use with L<autobox>. It does this using a hierarchy of
566roles in a manner similar to what Perl 6 I<might> do. This module,
567like L<Class::MOP> and L<Moose>, was inspired by my work on the
568Perl 6 Object Space, and the 'core types' implemented there.
569
570=head2 A quick word about autobox
571
572The L<autobox> module provides the ability for calling 'methods'
573on normal Perl values like Scalars, Arrays, Hashes and Code
574references. This gives the illusion that Perl's types are first-class
575objects. However, this is only an illusion, albeit a very nice one.
576I created this module because L<autobox> itself does not actually
577provide an implementation for the Perl types but instead only provides
578the 'hooks' for others to add implementation too.
579
580=head2 Is this for real? or just play?
581
582My intent is to try and make this module as production worthy as
583possible. This may or may not be possible, depending on how well
584L<autobox> works out. At this point, I have high hopes for things
585but only time (and more tests and code) will tell.
586
587=head1 ROLES
588
589This is a rough diagram of the roles involved to get our 4
590autoboxed types (SCALAR, ARRAY, HASH & CODE).
591
592 +------------------------+-------------------------------+
593 | Identity | Behavioral |
594 +------------------------+-------------------------------+
595 | Item | |
596 | Undef | |
597 | Defined | |
598 | Scalar* <-|- String, Number <--+ |
599 | Ref | |-- Value |
600 | Array* <-|- List <------------+ |
601 | Hash* | |
602 | Code* | |
603 | | |
604 +------------------------+-------------------------------+
605
606 * indicates actual autoboxed types
607
608=head1 TODO
609
610=over 4
611
612=item More docs
613
614=item More tests
615
616=back
617
618=head1 NOTES
619
620 - String, Number & List are currently the only 'Value's.
621
622 - Indexed is pretty much an interface, we probably will
623 need more of these (see Smalltalk Collection Trait
624 Refactoring)
625
626=head1 BUGS
627
628All complex software has bugs lurking in it, and this module is no
629exception. If you find a bug please either email me, or add the bug
630to cpan-RT.
631
632=head1 AUTHOR
633
634Stevan Little E<lt>stevan@iinteractive.comE<gt>
635
636=head1 COPYRIGHT AND LICENSE
637
638Copyright 2006 by Infinity Interactive, Inc.
639
640L<http://www.iinteractive.com>
641
642This library is free software; you can redistribute it and/or modify
643it under the same terms as Perl itself.
644
645=cut
646
647package Moose::Autobox;
648
649use strict;
650use warnings;
651
652use Carp qw(confess);
653use Scalar::Util ();
654
655our $VERSION = '0.02';
656
657package Moose::Autobox::SCALAR;
658# NOTE:
659# this doesnt make sense, but
660# I need to prevent Moose from
661# assiging to @ISA
662use base 'UNIVERSAL';
663use Moose;
664with 'Moose::Autobox::Scalar';
665
666*does = \&Moose::Object::does;
667
668package Moose::Autobox::ARRAY;
669use base 'UNIVERSAL';
670use Moose;
671with 'Moose::Autobox::Array';
672
673*does = \&Moose::Object::does;
674
675package Moose::Autobox::HASH;
676use base 'UNIVERSAL';
677use Moose;
678with 'Moose::Autobox::Hash';
679
680*does = \&Moose::Object::does;
681
682package Moose::Autobox::CODE;
683use base 'UNIVERSAL';
684use Moose;
685with 'Moose::Autobox::Code';
686
687*does = \&Moose::Object::does;
688
5f654d8e 6891;
690
691__END__
692
693=pod
694
695=head1 NAME
696
8937074a 697Moose::Autobox - Autoboxed for her pleasure
5f654d8e 698
699=head1 SYNOPOSIS
700
39894c95 701 use Moose::Autobox;
702 use autobox;
31d40d73 703
8937074a 704 print 'Print squares from 1 to 10 : ';
705 print [ 1 .. 10 ]->map(sub { $_ * $_ })->join(', ');
706
707=head1 CAVEAT
708
709First, a warning.
710
711This module is very very very very very very very experimental. It
712makes use of a very experimental module (L<autobox>) and uses some
713shiney new technology (L<Moose::Role>) to accomplish it's goals.
714
715Use this at your own risk. If it breaks the lamp in the living room
716and your mother yells at you, don't come complaining to me.
39894c95 717
1972aa1b 718Also, as this is so experimental, it's API should not be considered
719to be stable. It could very well change in radical ways.
720
5f654d8e 721=head1 DESCRIPTION
722
8937074a 723Moose::Autobox provides an implementation of SCALAR, ARRAY, HASH
724& CODE for use with L<autobox>. It does this using a hierarchy of
725roles in a manner similar to what Perl 6 I<might> do. This module,
726like L<Class::MOP> and L<Moose>, was inspired by my work on the
727Perl 6 Object Space, and the 'core types' implemented there.
728
729=head2 A quick word about autobox
730
731The L<autobox> module provides the ability for calling 'methods'
732on normal Perl values like Scalars, Arrays, Hashes and Code
733references. This gives the illusion that Perl's types are first-class
734objects. However, this is only an illusion, albeit a very nice one.
735I created this module because L<autobox> itself does not actually
736provide an implementation for the Perl types but instead only provides
737the 'hooks' for others to add implementation too.
738
739=head2 Is this for real? or just play?
740
741My intent is to try and make this module as production worthy as
742possible. This may or may not be possible, depending on how well
743L<autobox> works out. At this point, I have high hopes for things
744but only time (and more tests and code) will tell.
745
39894c95 746=head1 ROLES
8937074a 747
748This is a rough diagram of the roles involved to get our 4
749autoboxed types (SCALAR, ARRAY, HASH & CODE).
260cc81f 750
751 +------------------------+-------------------------------+
752 | Identity | Behavioral |
753 +------------------------+-------------------------------+
754 | Item | |
755 | Undef | |
756 | Defined | |
757 | Scalar* <-|- String, Number <--+ |
758 | Ref | |-- Value |
759 | Array* <-|- List <------------+ |
760 | Hash* | |
761 | Code* | |
762 | | |
763 +------------------------+-------------------------------+
764
39894c95 765 * indicates actual autoboxed types
1972aa1b 766
767=head1 TODO
768
769=over 4
770
771=item More docs
772
773=item More tests
774
775=back
31d40d73 776
777=head1 NOTES
778
8937074a 779 - String, Number & List are currently the only 'Value's.
31d40d73 780
781 - Indexed is pretty much an interface, we probably will
782 need more of these (see Smalltalk Collection Trait
783 Refactoring)
784
5f654d8e 785=head1 BUGS
786
787All complex software has bugs lurking in it, and this module is no
788exception. If you find a bug please either email me, or add the bug
789to cpan-RT.
790
791=head1 AUTHOR
792
793Stevan Little E<lt>stevan@iinteractive.comE<gt>
794
795=head1 COPYRIGHT AND LICENSE
796
797Copyright 2006 by Infinity Interactive, Inc.
798
799L<http://www.iinteractive.com>
800
801This library is free software; you can redistribute it and/or modify
802it under the same terms as Perl itself.
803
5f654d8e 804=cut