From: John Goulah Date: Tue, 3 Jun 2008 04:23:04 +0000 (+0000) Subject: first stab at a reserved keyword doc X-Git-Tag: 0_55~128 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4499a7ab1162076b17829ac96608ce389e96021a;p=gitmo%2FMoose.git first stab at a reserved keyword doc --- diff --git a/lib/Moose/Cookbook/Snack/Keywords.pod b/lib/Moose/Cookbook/Snack/Keywords.pod new file mode 100644 index 0000000..11178a3 --- /dev/null +++ b/lib/Moose/Cookbook/Snack/Keywords.pod @@ -0,0 +1,132 @@ +=pod + +=head1 NAME + +Moose::Cookbook::Snack::Keywords - Restricted keywords in Moose + +=cut + +=head1 DESCRIPTION + +There are several keywords exported in L that cause clashes against +any barewords such as attribute names, sub names, and globs. + + +=head2 The 'meta' keyword + +While most of the reserved keywords collisions can be avoided, however +I is the only one you B override. Do not attempt to override +I. + +=head2 Moose Keywords + +If you are using Moose its best to avoid these keywords + +=over 4 + +=item extends + +=item with + +=item has + +=item before + +=item after + +=item around + +=item super + +=item override + +=item inner + +=item augment + +=item make_immutable + +=item confess + +=item blessed + +=back + +=head2 Moose::Util::TypeConstraints Keywords + +If you are using Moose::Util::TypeConstraints its best to avoid +these keywords + +=over 4 + +=item type + +=item subtype + +=item class_type + +=item role_type + +=item as + +=item where + +=item message + +=item optimize_as + +=item coerce + +=item from + +=item via + +=item enum + +=item find_type_constraint + +=item register_type_constraint + +=back + +=head2 Avoiding collisions + +=head3 Turning off Moose + +To remove the keywords Moose exports using no Moose at the bottom of your code + + package Thing; + use Moose; + + # code here + + no Moose; + +=head3 Sub::Exporter + +The L module can rename keywords + + package LOL::Cat; + use Moose 'has' => { -as => 'i_can_haz' }; + + i_can_haz 'cheeseburger' => ( + is => 'rw', + trigger => sub { print "NOM NOM" } + ); + + LOL::Cat->new->cheeseburger('KTHNXBYE');; + +=head3 namespace::clean + +You can use L to clean up the namespace + +=head1 AUTHOR AND COPYRIGHT + +John Goulah Cjgoulah@cpan.org> + +=head1 LICENSE + +This program is free software; you can redistribute it and/or modify +it under the same terms as perl itself. + +=cut