Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 46354
Status: resolved
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: kane [...] cpan.org
Cc:
AdminCc:

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



Subject: attributes with lazy/lazy_build become 'required', but docs don't mention this.
See the attached script; it shows that lazy attributes become 'required' according to the meta code. However, this isn't mentioned in the docs: http://search.cpan.org/~drolsky/Moose-0.79/lib/Moose/Meta/Attribute.pm#Creation http://search.cpan.org/~drolsky/Moose-0.79/lib/Moose/Manual/Attributes.pod#Laziness_and_lazy_build I'm not sure what a better wording would be, but stating explicitly that this generates the equivalent of C<required => 1> is probably a good idea
Subject: z.pl
package Foo; use Moose; has normal => ( is => 'ro', default => 1, ); has lazy => ( is => 'ro', lazy_build => 1, ); has must => ( is => 'ro', default => 1, required => 1, ); sub _build_lazy { 1 }; package main; my $foo = Foo->new; print map { $_->reader . " is required\n" } grep { $_->is_required and not $_->is_lazy } $foo->meta->get_all_attributes; __END__ $ perl tmp/z.pl lazy is required must is required
On Mon May 25 11:45:37 2009, KANE wrote: Show quoted text
> See the attached script; it shows that lazy attributes become > 'required' > according to the meta code. However, this isn't mentioned in the docs:
Actually this only affects attributes with lazy_build enabled, lazy alone does not cause required to be enabled. Show quoted text
> http://search.cpan.org/~drolsky/Moose- > 0.79/lib/Moose/Meta/Attribute.pm#Creation > > http://search.cpan.org/~drolsky/Moose- > 0.79/lib/Moose/Manual/Attributes.pod#Laziness_and_lazy_build > > I'm not sure what a better wording would be, but stating explicitly > that > this generates the equivalent of C<required => 1> is probably a good > idea
Commit 24b0aad2dd056a372ccf4c80766b98d31ead7101 removes required => 1 from lazy_build's enabled features. This is the results of a conversation from earlier today. Alternatively there is a branch that documents this "feature" if it is decided to keep it.
Thanks Chris!
Thanks Chris!