Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / Moose / Cookbook / Basics / Recipe7.pod
1
2 =pod
3
4 =head1 NAME
5
6 Moose::Cookbook::Basics::Recipe7 - Making Moose fast with immutable
7
8 =head1 SYNOPSIS
9
10   package Point;
11   use Moose;
12
13   has 'x' => ( isa => 'Int', is => 'ro' );
14   has 'y' => ( isa => 'Int', is => 'rw' );
15
16   __PACKAGE__->meta->make_immutable;
17
18 =head1 DESCRIPTION
19
20 The Moose metaclass API provides a C<make_immutable()> method. Calling
21 this method does two things to your class. First, it makes it
22 faster. In particular, object construction and destruction are
23 effectively "inlined" in your class, and no longer invokes the meta
24 API.
25
26 Second, you can no longer make changes via the metaclass API, such as
27 adding attributes. In practice, this won't be a problem, as you rarely
28 need to do this after first loading the class.
29
30 =head1 CONCLUSION
31
32 We strongly recommend you make your classes immutable. It makes your
33 code much faster, with a small compile-time cost. This will be
34 especially noticeable when creating many object.
35
36 =head1 AUTHOR
37
38 Dave Rolsky E<lt>autarch@urth.orgE<gt>
39
40 =head1 COPYRIGHT AND LICENSE
41
42 Copyright 2006-2009 by Infinity Interactive, Inc.
43
44 L<http://www.iinteractive.com>
45
46 This library is free software; you can redistribute it and/or modify
47 it under the same terms as Perl itself.
48
49 =cut