some more docs for Class::MOP and the attribute functions for Class::MOP::Class
[gitmo/Class-MOP.git] / lib / Class / MOP.pm
1
2 package Class::MOP;
3
4 use strict;
5 use warnings;
6
7 use Scalar::Util 'blessed';
8
9 our $VERSION = '0.01';
10
11 # my %METAS;
12 # sub UNIVERSAL::meta { 
13 #     my $class = blessed($_[0]) || $_[0];
14 #     $METAS{$class} ||= Class::MOP::Class->initialize($class) 
15 # }
16
17 1;
18
19 __END__
20
21 =pod
22
23 =head1 NAME 
24
25 Class::MOP - A Meta Object Protocol for Perl 5
26
27 =head1 SYNOPSIS
28
29   # ... coming soon
30
31 =head1 DESCRIPTON
32
33 This module is an attempt to create a meta object protocol for the 
34 Perl 5 object system. It makes no attempt to change the behavior or 
35 characteristics of the Perl 5 object system, only to create a 
36 protocol for its manipulation and introspection.
37
38 That said, it does attempt to create the tools for building a rich 
39 set of extensions to the Perl 5 object system. Every attempt has been 
40 made for these tools to keep to the spirit of the Perl 5 object 
41 system that we all know and love.
42
43 =head2 What is a Meta Object Protocol?
44
45 A meta object protocol is an API to an object system. 
46
47 To be more specific, it is a set of abstractions of the components of 
48 an object system (typically things like; classes, object, methods, 
49 object attributes, etc.). These abstractions can then be used to both 
50 inspect and manipulate the object system which they describe.
51
52 It can be said that there are two MOPs for any object system; the 
53 implicit MOP, and the explicit MOP. The implicit MOP handles things 
54 like method dispatch or inheritance, which happen automatically as 
55 part of how the object system works. The explicit MOP typically 
56 handles the introspection/reflection features of the object system. 
57 All object systems have implicit MOPs, without one, they would not 
58 work. Explict MOPs however as less common, and depending on the 
59 language can vary from restrictive (Reflection in Java or C#) to 
60 wide open (CLOS is a perfect example). 
61
62 =head2 Yet Another Class Builder!! Why?
63
64 This is B<not> a class builder so much as it is a I<class builder 
65 B<builder>>. My intent is that an end user does not use this module 
66 directly, but instead this module is used by module authors to 
67 build extensions and features onto the Perl 5 object system. 
68
69 =head2 Who is this module for?
70
71 This module is specifically for anyone who has ever created or 
72 wanted to create a module for the Class:: namespace. The tools which 
73 this module will provide will hopefully make it easier to do more 
74 complex things with Perl 5 classes by removing such barriers as 
75 the need to hack the symbol tables, or understand the fine details 
76 of method dispatch. 
77
78 =head2 What changes do I have to make to use this module?
79
80 This module was designed to be as unintrusive as possible. So many of 
81 it's features are accessible without B<any> change to your existsing 
82 code at all. It is meant to be a compliment to your existing code and 
83 not an intrusion on your code base.
84
85 The only feature which requires additions to your code are the 
86 attribute handling and instance construction features. The only reason 
87 for this is because Perl 5's object system does not actually have 
88 these features built in. More information about this feature can be 
89 found below.
90
91 =head2 A Note about Performance?
92
93 It is a common misconception that explict MOPs are performance drains. 
94 But this is not a universal truth at all, it is an side-effect of 
95 specific implementations. For instance, using Java reflection is much 
96 slower because the JVM cannot take advantage of any compiler 
97 optimizations, and the JVM has to deal with much more runtime type 
98 information as well. Reflection in C# is marginally better as it was 
99 designed into the language and runtime (the CLR). In contrast, CLOS 
100 (the Common Lisp Object System) was built to support an explicit MOP, 
101 and so performance is tuned for it. 
102
103 This library in particular does it's absolute best to avoid putting 
104 B<any> drain at all upon your code's performance, while still trying 
105 to make sure it is fast as well (although only as a secondary 
106 concern).
107
108 =head1 PROTOCOLS
109
110 The protocol is divided into 3 main sub-protocols:
111
112 =over 4
113
114 =item The Class protocol
115
116 This provides a means of manipulating and introspecting a Perl 5 
117 class. It handles all of symbol table hacking for you, and provides 
118 a rich set of methods that go beyond simple package introspection.
119
120 See L<Class::MOP::Class> for more details.
121
122 =item The Attribute protocol
123
124 This provides a consistent represenation for an attribute of a 
125 Perl 5 class. Since there are so many ways to create and handle 
126 atttributes in Perl 5 OO, this attempts to provide as much of a 
127 unified approach as possible, while giving the freedom and 
128 flexibility to subclass for specialization.
129
130 See L<Class::MOP::Attribute> for more details.
131
132 =item The Method protocol
133
134 This provides a means of manipulating and introspecting methods in 
135 the Perl 5 object system. As with attributes, there are many ways to 
136 approach this topic, so we try to keep it pretty basic, while still 
137 making it possible to extend the system in many ways.
138
139 See L<Class::MOP::Method> for more details.
140
141 =back
142
143 =head1 SEE ALSO
144
145 =head2 Books
146
147 =over 4
148
149 =item "The Art of the Meta Object Protocol"
150
151 =item "Advances in Object-Oriented Metalevel Architecture and Reflection"
152
153 =back
154
155 =head2 Prior Art
156
157 =over 4
158
159 =item The Perl 6 MetaModel work
160
161 =over 4
162
163 =item L<http://svn.openfoundry.org/pugs/perl5/Perl6-MetaModel>
164
165 =item L<http://svn.openfoundry.org/pugs/perl5/Perl6-ObjectSpace>
166
167 =back
168
169 =back
170
171 =head1 AUTHOR
172
173 Stevan Little E<gt>stevan@iinteractive.comE<lt>
174
175 Rob Kinyon E<gt>rob@iinteractive.comE<lt>
176
177 =head1 COPYRIGHT AND LICENSE
178
179 Copyright 2006 by Infinity Interactive, Inc.
180
181 L<http://www.iinteractive.com>
182
183 This library is free software; you can redistribute it and/or modify
184 it under the same terms as Perl itself. 
185
186 =cut