From: Matt S Trout Date: Sat, 16 Mar 2013 20:01:00 +0000 (+0000) Subject: clean up docs on default and incompatibility X-Git-Tag: v1.001000~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0e43f98f09d3ca6c08fde835d263da0e8530c2dd;p=gitmo%2FMoo.git clean up docs on default and incompatibility --- diff --git a/lib/Moo.pm b/lib/Moo.pm index 2e9ff7a..a5140b0 100644 --- a/lib/Moo.pm +++ b/lib/Moo.pm @@ -548,6 +548,10 @@ to populate an attribute if no value is supplied to the constructor - or if the attribute is lazy, when the attribute is first retrieved if no value has yet been provided. +If a simple scalar is provided, it will be inlined as a string. Any non-code +reference (hash, array) will result in an error - for that case instead use +a code reference that returns the desired value. + Note that if your default is fired during new() there is no guarantee that other attributes have been populated yet so you should not rely on their existence. @@ -704,7 +708,7 @@ API will encourage the use of other type systems as well, since it's probably the weakest part of Moose design-wise. C is not supported in core since the author considers it to be a -bad idea but may be supported by an extension in future. Meanwhile C or +bad idea and Moose best practices recommend avoiding it. Meanwhile C or C are more likely to be able to fulfill your needs. There is no meta object. If you need this level of complexity you wanted @@ -735,13 +739,15 @@ The C method is not provided by default. The author suggests loading L into C (via C for example) and using C<$obj-E$::Dwarn()> instead. -L only supports coderefs, because doing otherwise is usually a -mistake anyway. +L only supports coderefs and plain scalars, because passing a hash +or array reference as a default is almost always incorrect since the value is +then shared between all objects using that default. C is not supported; you are instead encouraged to use the C<< is => 'lazy' >> option supported by L and L. -C is not supported since the author considers it a bad idea. +C is not supported since the author considers it a bad idea and +it has been considered best practice to avoid it for some time. C will show up in a L metaclass created from your class but is otherwise ignored. Then again, L ignores it as well, so this