Am Freitag, den 16.10.2009, 10:54 +0400 schrieb Richard Hainsworth:
> Arising out of "Freezing Roles" is a related question.
> 
> Suppose I download a module from CPAN with a role I want to use, but it 
> introduces a method that I want that is in conflict with an existing 
> method (say one taken from another CPAN module).
> 
> How should the method be aliased to prevent it from causing a conflict 
> at class composition time?

I personally don't anderstand why we don't have a exclude and alias
operator in Perl 6 but I have not read all the synopses and don't have
an overview.

In the thread "Re: YAPC::EU and Perl 6 Roles" in last july I already
said the following:
---snipp---
> The brilliant idea with "traits" is that it bring back the control to
> the class consuming the "trait" and conflicts have to be solved
> explicitly. The traits paper propose 3 different operators to solve
> such conflicts: overriding, excluding or aliasing.
> 
> I definitively think that perl 6 roles should also have an excluding
> operator because I think that *every* composition conflicts arrising
> should be solvable by the class comsuming the role.
---snapp---

As a side note, Johnatan give us a example about how to make an alias
with user defined traits, but it doesn't help here because a trait is
bound to a definition:
http://use.perl.org/~JonathanWorthington/journal/39504
My anderstanding is also that that kind of aliasing as defined with a
trait is "deep": If you alias a recursive method, the call will be done
to the aliased one (or am I wrong?).
In the original traits paper the aliasing is not "deep": to respect the
flattening property, the semantic of the role must not change, so
aliasing a recursive method will call the original method. It's a known
theoretical weakness of the traits paper and "freezing roles" try to
solve this problem.

Finally, the interaction between module and role is also interesting and
it's not clear to me how Perl 6 solve it: I send a question this August
to the mailinglist but sadly had no reply, see "Perl 6 modules and
classboxes?":
---snipp---
As Perl 6 will be supporting multiple versions installed of the same
module and also support import with lexical scoping, I was asking myself
if it was possible to combine some of the interresting properties of
classboxes like local rebinding, flattening property and the idea that
import takes precedence over inheritance.

I am absolutly not sure if it fit to the Perl 6 module concept as a
whole, but I will be happy to read your comments and what you think
about it.

A few pointers:

classboxes+traits introduction:
http://scg.unibe.ch/archive/papers/Berg05dTraitsClassbox.pdf

For an in depth description, you can also read the Ph.D. thesis:
http://scg.unibe.ch/archive/phd/bergel-phd.pdf

To develop the classbox concept, the autors also introduced a module
calculus, which also help to describe the difference existing beetween
different modules systems: (such a module calculus can also help to
better anderstand the interaction beetween different languages): 
http://scg.unibe.ch/archive/papers/Berg05cModuleDiversity.pdf
---snapp---

Raphael


Reply via email to