in reply to Psychic Disconnect and Object Systems
but the framers of the system decided this was the normal thing to do
How so? They didn't do anything to hinder what you want to do whatsoever.
around BUILDARGS => sub { my $orig = shift; my $class = shift; ... return $class->$orig(...); };
is slightly more wordy than
sub new { my $class = shift; ... return $class->SUPER::new(...); }
But surely you don't have a problem with that??
(Upd: By the way, you can use the latter, but overriding BUILDARGS allows Moose to do some optimisations. )
Second, what is the point of a read-only attribute? If it can't be set, it will never exist. There must be some "but..." in there.
is => 'ro' is simply a shortcut for reader => $name, and is => 'rw' is simply a shortcut for accessor => $name. It's more "write-once" than "read-only" since neither prevents the the constructor from initialising the attribute, and neither prevents defaults (including those that may be determined from other fields or from external data) from initialising the attribute.
So how do I make attributes that are for internal use?
has attr => ( reader => '_get_attr', writer => '_set_attr', handles => { get_attr => sub { ... }, set_attr => sub { ... }, }, )
(Upd: Sorry, I thought you were asking about internal use accessors. )
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Psychic Disconnect and Object Systems
by educated_foo (Vicar) on Apr 15, 2011 at 17:18 UTC | |
by ikegami (Patriarch) on Apr 15, 2011 at 17:31 UTC | |
by educated_foo (Vicar) on Apr 15, 2011 at 22:16 UTC | |
by ikegami (Patriarch) on Apr 15, 2011 at 22:47 UTC | |
by ikegami (Patriarch) on Apr 15, 2011 at 22:52 UTC | |
|
Re^2: Psychic Disconnect and Object Systems
by John M. Dlugosz (Monsignor) on Apr 18, 2011 at 01:42 UTC | |
by ikegami (Patriarch) on Apr 18, 2011 at 02:33 UTC |