On 02/01/2012 11:41 PM, Carl Mäsak wrote:
> Getting back to the topic of the original post: I think "blessall" is
> a bad name for what's proposed, and I don't see a fantastically large
> need for that functionality. What's wrong with just defining a BUILD
> submethod in the class?
The current approach is violating the DRY principle. When you write a
.new method that wants to initialize private attributes, you have to
repeat all their names again in the signature of your BUILD submethod:
class A {
has ($!x, $!y, $!z);
method new($x, $y, $z) { self.bless(*, :$x, :$y, :$z) }
submethod BUILD(:$!x, :$!y, :$!z) { } # is this repetition really
needed?
}
It also means that private attributes are less convenient to work with
than those with accessors, which IMHO is a not signal in the right
direction.
Cheers,
Moritz