It still seems wrong to me that a writer should exist, and work, on a ro attribute
Well, really the 'ro' and 'rw' are just shorthand for the various combinations of 'reader', 'writer' and 'accessor'. So a 'ro' attribute is just shorthand for:
has 'foo' => ( reader => 'foo' );
And a 'rw' attribute is just shorthand for:
has 'foo' => ( accessor => 'foo' );
It is also quite possible to do really weird things like:
has 'foo' => ( reader => 'get_foo', writer => 'set_foo', accessor => '
+foo' );
which may seem odd, but could be very useful in some situations where the API requires it. This is all part of Moose's policy to provide the best practices at your fingertips, but not get in the way when you need to do something weird, which if you think about it is not all that different from Perl itself.
|