X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FManual%2FClasses.pod;h=c128096fa34112c3c14e86ba210d049ab04c36ba;hb=4b9d46665d73a88477673bed833cc46efeb2e2e8;hp=7183de9c9c1a368cc0e4fac6af3f30e4eb878030;hpb=dab940632264ba728cdd882436a2c972f001fecf;p=gitmo%2FMoose.git diff --git a/lib/Moose/Manual/Classes.pod b/lib/Moose/Manual/Classes.pod index 7183de9..c128096 100644 --- a/lib/Moose/Manual/Classes.pod +++ b/lib/Moose/Manual/Classes.pod @@ -17,10 +17,9 @@ That's it, you've made a class with Moose! There's actually a lot going on here under the hood, so let's step through it. -When you load L, a bunch of sugar functions are exported into -your class. These include things like C, C, C, and -more. These functions are what you use to define your class. For -example, you might define an attribute ... +When you load L, a bunch of sugar functions are exported into your +class, such as C, C, C, and more. These functions are what +you use to define your class. For example, you might define an attribute ... package Person; @@ -31,7 +30,7 @@ example, you might define an attribute ... Attributes are described in the L documentation. -Loading Moose also enables C and C pragmas in your +Loading Moose also enables the C and C pragmas in your class. When you load Moose, your class will become a subclass of @@ -76,23 +75,44 @@ also called C). In that case, you will have to take care of initializing attributes manually, either in the parent's constructor, or in your subclass, and you will lose a lot of Moose magic. -=head1 NO MOOSE +See the L module on CPAN if you're interested in extending +non-Moose parent classes with Moose child classes. -Moose also allows you to remove its sugar functions from your class's -namespace. We recommend that you take advantage of this feature, since -it just makes your classes "cleaner". You can do this by simply adding -C at the end of your module file. +=head1 CLEANING UP MOOSE DROPPINGS -This deletes Moose's sugar functions from your class's namespace, so -that C<< Person->can('has') >> will no longer return true. +Moose exports a number of functions into your class. It's a good idea to +remove these sugar functions from your class's namespace, so that C<< +Person->can('has') >> will no longer return true. + +There are several ways to do this. We recommend using L, +a CPAN module. Not only will it remove Moose exports, it will also remove +any other exports. + + package Person; + + use namespace::autoclean; + + use Moose; + +If you absolutely can't use a CPAN module (but can use Moose?), you can write +C at the end of your class. This will remove any Moose exports in +your class. + + package Person; + + use Moose; + + has 'ssn' => ( is => 'rw' ); + + no Moose; =head1 MAKING IT FASTER Moose has a feature called "immutabilization" that you can use to -greatly speed up your classes at runtime. However, using it does incur +greatly speed up your classes at runtime. However, using it incurs a cost when your class is first being loaded. When you make your class immutable you tell Moose that you will not be changing it in the -future. You will not adding any more attributes, methods, roles, etc. +future. You will not be adding any more attributes, methods, roles, etc. This allows Moose to generate code specific to your class. In particular, it creates an "inline" constructor, making object