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