develooper Front page | perl.perl6.language | Postings from October 2005

Roles vs. Classes (was Re: Ways to add behavior)

Thread Next
From:
Rob Kinyon
Date:
October 26, 2005 17:29
Subject:
Roles vs. Classes (was Re: Ways to add behavior)
Message ID:
70384420510261729x3122a1banbf07100bfeb1e4ce@mail.gmail.com
> : 3) Aren't classes mutable and roles immutable by default only? Or has
> : this changed?
>
> Of course.  To change the default for a role, call it a class, and
> to change the default for a class, call it a role.  :-)

Does this mean that roles are the recommended way to create immutable
classes? Given that roles and classes now seem to differ only in their
mutability, I can't see a reason why I would use class as my default
object definer. I would prefer to use roles as they're closed by
default, leaving "class" to be my powertool, if I need the power.

Rob

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About