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"?
In reply to Re^2: Psychic Disconnect and Object Systems
by educated_foo
in thread Psychic Disconnect and Object Systems
by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |