David Storrs writes:
> 
> On Sat, Dec 13, 2003 at 11:12:31AM -0800, Larry Wall wrote:
> > On Sat, Dec 13, 2003 at 04:57:17AM -0700, Luke Palmer wrote:
> 
> > : For one, one role's methods don't silently override another's.  Instead,
> > : you get, er, role conflict and you have to disambiguate yourself.  
> 
> How do you disambiguate?

Let's see...

    role Dog {
        method bark() { print "Ruff!" }
    }
    role Tree {
        method bark() { print "Rough!" }
    }
    class Trog 
      does Dog does Tree {
        method bark() { .Dog::bark() }
      }
    }

Perhaps something like that.  In any case, you do it by putting the
offending method directly in the aggregating class.

> After reading this several times, I _think_ I understand.  Let me
> check: imagine that the original class is a text buffer going from
> 0-99.  We have two roles (A and B), each of length 100.  Objects of
> various types can then see different segments of the buffer (i.e.,
> different methods/properties/whatever), as follows:
> 
>       Type            Can see 
>       ----            -------
>       Class           1-100           
>       A               101-199
>       B               200-299
>       Class+A         1-100,101-199
>       Class+B         1-100,200-299
>       Class+A+B       1-100,101-199,200-299
> 
> Is that right?

Umm... I'm not sure that's what I'd use roles for.  And I'm not sure how
roles with associated data are supposed to work yet.  But I think you
have the general idea.

Luke

Reply via email to