develooper Front page | perl.perl6.language | Postings from January 2004

Re: Roles and Mix-ins?

Thread Previous | Thread Next
From:
Piers Cawley
Date:
January 7, 2004 00:11
Subject:
Re: Roles and Mix-ins?
Message ID:
m2fzes6uw2.fsf@obelisk.bofh.org.uk
Jonathan Lang <dataweaver42@yahoo.com> writes:

> Luke Palmer wrote:
>> Renaming methods defeats the purpose of roles.  Roles are like
>> interfaces inside-out.  They guarantee a set of methods -- an interface
>> -- except they provide the implementation to (in terms of other,
>> required methods).  Renaming the method destroys the interface
>> compatibility.
>
> Not so.  A role is more than an inside-out interface; it guarantees a set
> of methods either by calling it an error to not define a given method in a
> class that C<does> the role or by defining the method itself.  In the
> latter case, renaming the method can be quite useful; even in the former
> case, renaming or excluding methods from a role is useful if you want an
> interface which is almost, but not quite, like the one that the role
> provides.  

And examples of doing all of that are given in the original Traits
paper (and, for that matter, in the summary of Traits/Roles that I
wrote up for the summary.)

-- 
Beware the Perl 6 early morning joggers -- Allison Randal

Thread Previous | 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