Rename Basics::Recipe6 to Basics::Document_AugmentAndInner
[gitmo/Moose.git] / lib / Moose / Cookbook / Basics / Immutable.pod
1 package Moose::Cookbook::Basics::Immutable;
2
3 # ABSTRACT: Making Moose fast by making your class immutable
4
5 __END__
6
7
8 =pod
9
10 =head1 SYNOPSIS
11
12   package Point;
13   use Moose;
14
15   has 'x' => ( isa => 'Int', is => 'ro' );
16   has 'y' => ( isa => 'Int', is => 'rw' );
17
18   __PACKAGE__->meta->make_immutable;
19
20 =head1 DESCRIPTION
21
22 The Moose metaclass API provides a C<make_immutable()> method. Calling
23 this method does two things to your class. First, it makes it
24 faster. In particular, object construction and destruction are
25 effectively "inlined" in your class, and no longer invoke the meta
26 API.
27
28 Second, you can no longer make changes via the metaclass API, such as
29 adding attributes. In practice, this won't be a problem, as you rarely
30 need to do this after first loading the class.
31
32 =head1 CONCLUSION
33
34 We strongly recommend you make your classes immutable. It makes your
35 code much faster, with a small compile-time cost. This will be
36 especially noticeable when creating many objects.
37
38 =cut