Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 121749
Status: new
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: boris.voskr [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: fix documentation regarding lazy-ness of required attributes
Date: Wed, 17 May 2017 10:16:22 -0500
To: bug-Moose [...] rt.cpan.org
From: Boris V <boris.voskr [...] gmail.com>
Quote from Attributes.pod <http://search.cpan.org/~ether/Moose-2.2004/lib/Moose/Manual/Attributes.pod#Required_or_not?> : There are a couple caveats worth mentioning in regards to what "required" Show quoted text
> actually means. > Basically, all it says is that this attribute (name) must be provided to > the constructor, *or be lazy* with either a default or a builder.
In reality, current Moose (2.2004) implementation does not require lazy-ness for setting a required attribute with default (if the attribute is not given to the constructor). Simply having a default or builder is enough. If needed, I can provide an example proving it. Also, let me point to the place in the Moose code, which confirms my observation: $ head -n 61 Moose/lib/Class/MOP/Attribute.pm | tail -n 5 Show quoted text
> if( $options{required} and not( defined($options{builder}) || > defined($options{init_arg}) || exists $options{default} ) ) { > $class->_throw_exception( RequiredAttributeLacksInitialization => > class => $class, > params => > \%options > ); > }
I suggest to fix the pod document correspondingly. Regards, Boris.