On Fri, Mar 01, 2013 at 04:56:57PM +0000, Pedro Melo wrote:
> Hi,
> 
> I keep getting bitten by this, and I was wondering if this is
> something that will be solved eventually, or its something that would
> be nice to solve but it is actually tricky to do, or just that I'm
> doing it wrong.
> 
> I have two roles, R1 and R2. R1 defines a attribute ctx. R2 requires a 'ctx'.
> 
> If I use the two roles on a class C, with a single "with 'R1', 'R2';" I get
> 
>     'R1|R2' requires the method 'ctx' to be implemented by 'C'
> 
> I can work around it with two "with 'R1'; with 'R2';". But I loose all
> the other protections wrt duplicate methods I might have in R1 and R2.
> 
> Opinions?

This is something that we'd like to fix - the problem is mainly that
role accessors aren't generated until they are composed into a class,
but role application composes roles together before composing them into
the class. What we really need to do is provide a way for roles to say
"I'm going to generate a method of this name", which we would be able to
query during the role summation process (we can't actually generate the
methods themselves because doing so requires an instance metaclass,
which only classes have).

Patches to fix this would be appreciated.

-doy

Reply via email to