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