Exactly. Then again, implementing private methods is simple and straight forward. Plus, IMO, the proper way to design and implement OO right now on Perl 5 is only Moose.
Yeah that is right. Moose is the way you should use OOP in Perl today. I use it myself. I even look over MooseX::Declare and what he provides like MooseX::Method::Signatures or MooseX::MultiMethod it is awesome. But i never see private Methods in Perl, and i don't think it is easy to implement. (I don't speak of anonymous subroutines)
A "real" Private Method is something that in your own module you can just write "$self->something()" just like a normal method. But you can see "something()" only in your module. From outside of your module calling "something()" on the object then needs to throw an error that says that something() doesn't exists.
Even namespace::clean can't help you here.
Moose and his extensions are really great, but i don't see how you can implement private methods with it.
Moose itself does not provide Private Methods.
Sid Burn
17 Aug 09 at 5:20 am
Exactly. Then again, implementing private methods is simple and straight forward. Plus, IMO, the proper way to design and implement OO right now on Perl 5 is only Moose.
David Moreno
17 Aug 09 at 7:26 am
Yeah that is right. Moose is the way you should use OOP in Perl today. I use it myself. I even look over MooseX::Declare and what he provides like MooseX::Method::Signatures or MooseX::MultiMethod it is awesome. But i never see private Methods in Perl, and i don't think it is easy to implement. (I don't speak of anonymous subroutines)
A "real" Private Method is something that in your own module you can just write "$self->something()" just like a normal method. But you can see "something()" only in your module. From outside of your module calling "something()" on the object then needs to throw an error that says that something() doesn't exists.
Even namespace::clean can't help you here.
Moose and his extensions are really great, but i don't see how you can implement private methods with it.
Sid Burn
18 Aug 09 at 3:22 am
As far as I can tell, one _cannot_ implement the private concept in Perl 5.
A sub is always a sub in Perl 5 whatever the module/extension you're using to declare your classes.
The same goes for "private" attributes for a given object. You won't be able to prevent a user from accessing $self->{_my_really_private_stuff} …
Alexis Sukrieh
7 Oct 09 at 7:49 am