in reply to Re: Psychic Disconnect and Object Systems
in thread Psychic Disconnect and Object Systems
How so? They didn't do anything to hinder what you want to do whatsoever.The easiest thing to do is to use Moose's automatically-generated new, which does the thing the OP doesn't want. AFAICT "attributes" are the product of confusion between the view that an "object" is a collection of named bits of state, and the view that an "object" is a box to which you send "messages." People want "messages" telling the "object" "give me the value of this named bit of state," so "objects" have "attributes" by default.
is => 'ro' is simply a shortcut for reader => $name, and is => 'rw' is simply a shortcut for accessor => $name.But if you just do
You get read-only attributes by default. The OP's question is "why?" The answer usually leads to a religious war.has 'foo';
As for internal-use attributes, the OP is wondering what this does:
(I would test it myself, but don't have Moose lying around.)package Base; use Moose; has 'x', default => 'Base'; # internal sub foo { print shift->x; } package Child; use Moose; has 'x', default => 'Child'; # also internal package main; Base->new->foo; # "Base" Child->new->foo; # "Base" or "Child"?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Psychic Disconnect and Object Systems
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 |