From: Tomas Doran Date: Thu, 28 Aug 2008 14:56:38 +0000 (+0000) Subject: Add an explanation about Roles/Traits and the difference between them (or lack thereo... X-Git-Tag: 0.55_02~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a8de15f8b34818dd1923669609a3cbaed04cab02;p=gitmo%2FMoose.git Add an explanation about Roles/Traits and the difference between them (or lack thereof). Also drive-by speeling fixation --- diff --git a/lib/Moose/Cookbook/FAQ.pod b/lib/Moose/Cookbook/FAQ.pod index 193d6aa..ee14c71 100644 --- a/lib/Moose/Cookbook/FAQ.pod +++ b/lib/Moose/Cookbook/FAQ.pod @@ -85,7 +85,7 @@ or any other format To change the handling of individual parameters, there are I (See the L for a complete example and -explaination of coercions). With coercions it is possible to morph +explanation of coercions). With coercions it is possible to morph argument values into the correct expected types. This approach is the most flexible and robust, but does have a slightly higher learning curve. @@ -172,7 +172,7 @@ L. This will allow you to write: is => 'rw', ); -And have Moose create seperate C and C methods +And have Moose create separate C and C methods instead of a single C method. NOTE: This B be set globally in Moose, as that would break @@ -282,6 +282,24 @@ release. See L and specifically the B question in the B section. +=head3 What are Traits, and how are they different to Roles? + +In Moose, a trait is almost exactly the same thing as a role, except that +traits typically register themselves, and thus can be referred to by a short name. + +The word I is typically used to indicate a class building block, which +is composed into a class at class composition time, whereas I is used to +indicate functionality which is composed into an instance of a class at runtime +to add or modify the behavior of B. + +But this is all just convention, so don't take it too seriously - nobody +is going to yell at you if you use them interchangeably, or use one instead +of the other. + +Outside the context of Moose, traits and roles generally mean exactly the +same thing. The original paper called them Traits, however Perl 6 will call +them Roles. + =head1 AUTHOR Stevan Little Estevan@iinteractive.comE