NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Why...? (Score:1)
rjbs has explained what went wrong, but I'm curious why you'd expect it to behave differently. The behaviour is exactly as documented in Moose's section on is => 'rw'|'ro'.
Re: (Score:2)
Sorry about that. I just hastily threw together an example. But what's the value of allowing me to declare an attribute without an accessor or mutator? I'm sure there's a reason. I just don't see it.
Re: (Score:1)
The slot is still accessible via the MOP, which means other accessor-like methods can access it. For example, with MooseX-AttributeHelpers you could have an ArrayRef container providing push and pop methods without providing an API to directly set the array reference value.
Ordinary morality is for ordinary people. -- Aleister Crowley
Re: (Score:1)
It would be nice to have to explicitly request that, though? Instead of it being the silent default. Or else there might be
has_roandhas_rwkeywords that one could use for the bulk of one’s declarations, in which case it’d be immediately obvious when something uncommon is going on.Re: (Score:1)
Waiting on the Road to Eventually, I lost my Place On Line
Re: (Score:1)
At this point I doubt this is going to change in Moose, although MooseX::Declare might be open to new ideas.
MooseX::Declare is part of the overall Moose project, it will almost certainly not deviate too far from what Moose does on key issues like this. However which might be nice is to add support for the Perl-6 style of doing this, like so:
Here all of Foos attributes will be (is => rw) automagically. I think the key issue here is that Moose will not and should not do anything you don't ask it to do. DWIMery is very VERY slippery slope, too much o
Re: (Score:2)
My only suggestion is that the default be (is => 'ro') for reasons that I think are probably obvious to you. That being said, I accept an 'rw' default as most OO programmers are going to expect that an not agree that 'ro' is so important.
Re:Why...? (Score:1)
class Foo is ro {
has bar;
has baz;
}
# or in Plain Moose
{
package Foo;
use Moose -traits => ['ReadOnly'];
use namespace::autoclean;
has bar;
has baz;
__PACKAGE__->meta->make_immutable;
}
Reply to This
Parent