Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^5: Moose object construction

by stvn (Monsignor)
on Feb 11, 2011 at 00:47 UTC ( #887557=note: print w/replies, xml ) Need Help??

in reply to Re^4: Moose object construction
in thread Moose object construction

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.


Replies are listed 'Best First'.
Re^6: Moose object construction
by saintex (Scribe) on Feb 11, 2011 at 15:13 UTC
    Thank you all for suggestions!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://887557]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2018-01-17 13:29 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (200 votes). Check out past polls.