in reply to Re: Moose or Mouse for production use
in thread Moose or Mouse for production use
I have one more question:
In a previous project I've used Class::Std and I quite like the strong encapsulation for object-attributes it provides.
I just did some (very basic) playing around with Moose and wonder if there is any way to encapsulate object-attributes as well or if with Moose no access-control is possible.
For example I was very surprised that you could do the following:
<code>
use strict;
package Hubba;
use Moose;
has 'hubba' => ( is => "rw", isa => 'Int' );
package main;
no Moose;
my $h = Hubba->new;
$h->{hubba} = "Bubba";
print $h->hubba
</code>
This actually prints "Bubba". In this example I declare a "hubba"-attribute of a "Hubba"-class to be of type Int, but still it is possible to subvert the type-system by accessing the attribute directly (or am I doing something wrong?)
I don't think all of this will be a major concern for us, but still I would prefer stronger encapsulation - is that possible with Moose (or can you mix Moose and Class::Std)?
Many thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Moose or Mouse for production use
by stvn (Monsignor) on Apr 01, 2009 at 19:16 UTC | |
by roubi (Hermit) on Apr 01, 2009 at 22:02 UTC | |
by stvn (Monsignor) on Apr 01, 2009 at 23:55 UTC | |
by roubi (Hermit) on Apr 02, 2009 at 01:35 UTC | |
by stvn (Monsignor) on Apr 02, 2009 at 01:50 UTC | |
by stvn (Monsignor) on Apr 02, 2009 at 00:17 UTC | |
by tye (Sage) on Apr 02, 2009 at 04:32 UTC | |
|
Re^3: Moose or Mouse for production use
by roubi (Hermit) on Apr 01, 2009 at 16:44 UTC |