Re: A12: Conflicting Attributes in Roles

2004-04-23 Thread Larry Wall
On Fri, Apr 23, 2004 at 03:34:32PM -0700, Jonathan Lang wrote: : Larry Wall wrote: : > On Fri, Apr 23, 2004 at 02:37:58PM -0700, Jonathan Lang wrote: : > : Note that the problem extends past accessors: a role's methods can : > : access its attributes directly. So: : > : : > : role A {has Cat $.

Re: A12: Conflicting Attributes in Roles

2004-04-23 Thread Jonathan Lang
Larry Wall wrote: > On Fri, Apr 23, 2004 at 02:37:58PM -0700, Jonathan Lang wrote: > : Note that the problem extends past accessors: a role's methods can > : access its attributes directly. So: > : > : role A {has Cat $.x; method m1 {return $.x;};} > : role B {has Dog $.x; method m2 {return $

Re: A12: Conflicting Attributes in Roles

2004-04-23 Thread Larry Wall
On Fri, Apr 23, 2004 at 02:37:58PM -0700, Jonathan Lang wrote: : Note that the problem extends past accessors: a role's methods can access : its attributes directly. So: : : role A {has Cat $.x; method m1 {return $.x;};} : role B {has Dog $.x; method m2 {return $.x;};} : class Foo {does Cat

RE: A12: Conflicting Attributes in Roles

2004-04-23 Thread Dan Sugalski
At 2:37 PM -0700 4/23/04, Jonathan Lang wrote: Austin Hastings wrote: Jonathan Lang wrote: > role A {has Cat $.x;} > role B {has Dog $.x;} > class Foo {does Cat; does Dog;} > my Foo $bar; > $bar.x; # Is this a Cat or a Dog? If, however, two roles try to introduce a method of the same nam

RE: A12: Conflicting Attributes in Roles

2004-04-23 Thread Jonathan Lang
Austin Hastings wrote: > Jonathan Lang wrote: > > role A {has Cat $.x;} > > role B {has Dog $.x;} > > class Foo {does Cat; does Dog;} > > my Foo $bar; > > $bar.x; # Is this a Cat or a Dog? > > > If, however, two roles try to introduce a method of the same name (for > some definition of name), t

Re: A12: Conflicting Attributes in Roles

2004-04-23 Thread Aaron Sherman
On Fri, 2004-04-23 at 14:28, Aaron Sherman wrote: > I would expect wildcard delegation not to care about method conflicts at > all, since what's being done is, by its nature, much more dynamic > anyway. I misunderstood roles when I said this... I now get why this is a problem, sorry. -- Aaron S

RE: A12: Conflicting Attributes in Roles

2004-04-23 Thread Austin Hastings
> -Original Message- > From: Larry Wall [mailto:[EMAIL PROTECTED] > > On Fri, Apr 23, 2004 at 01:05:21PM -0400, Austin Hastings wrote: > : That seems like a good disambiguation marker, too: > : > : class Trog does Tree does Dog {...} > : > : # error: conflicting 'bark' methods > : > :

Re: A12: Conflicting Attributes in Roles

2004-04-23 Thread Aaron Sherman
On Fri, 2004-04-23 at 14:17, Larry Wall wrote: > : does Tree > : handles «bark» > : does Dog > That works in the case of an explicitly named method, since that > effectively makes .bark a method in the current class. It would not > work for a wildcard delegation though, unles

Re: A12: Conflicting Attributes in Roles

2004-04-23 Thread Larry Wall
On Fri, Apr 23, 2004 at 01:05:21PM -0400, Austin Hastings wrote: : That seems like a good disambiguation marker, too: : : class Trog does Tree does Dog {...} : : # error: conflicting 'bark' methods : : class Trog : is PersistentObject : handles «meta dispatch SERIALIZE» :

RE: A12: Conflicting Attributes in Roles

2004-04-23 Thread Austin Hastings
> -Original Message- > From: Aaron Sherman [mailto:[EMAIL PROTECTED] > > On Fri, 2004-04-23 at 11:44, Brent 'Dax' Royal-Gordon wrote: > > Aaron Sherman wrote: > > > > class c { does a for <>; does b for <>; } > > > Funny how similar that is to > > > > class c { does a handles <>; d

Re: A12: Conflicting Attributes in Roles

2004-04-23 Thread Aaron Sherman
On Fri, 2004-04-23 at 11:44, Brent 'Dax' Royal-Gordon wrote: > Aaron Sherman wrote: > > class c { does a for <>; does b for <>; } > Funny how similar that is to > > class c { does a handles <>; does b handles <>; } In "Relationship to Roles" A12 makes the point that delegation and rol

Re: A12: Conflicting Attributes in Roles

2004-04-23 Thread Brent 'Dax' Royal-Gordon
Aaron Sherman wrote: seen the "does b". You could assert the other way around: class c { does a for <>; does b for <>; } which is kind of nifty looking, but some may blanch at the dual meaning for "for" Funny how similar that is to class c { does a handles <>; does b handles <>; } -- B

Re: A12: Conflicting Attributes in Roles

2004-04-23 Thread Aaron Sherman
On Wed, 2004-04-21 at 12:17, chromatic wrote: > * Add a disambiguatey method to PoliceDog that dispatches > appropriately. (Insert handwavey "well you *could* do it this way or > you *might* do it that way.") I agree, but given that the average user should probably not have to interact with the

Re: A12: Conflicting Attributes in Roles

2004-04-21 Thread chromatic
On Wed, 2004-04-21 at 04:19, Buddha Buck wrote: > From one C6PAN module: > > role Dog { >has $.collar; >... > } > From a third C6PAN module: > > class PoliceDog does Dog does LawEnforcementOfficer { ... } > role LawEnforcementOfficer { >method arrest { ... } >has $.collar;

Re: A12: Conflicting Attributes in Roles

2004-04-21 Thread Buddha Buck
Originally sent to Austin alone by accident Austin Hastings wrote: -Original Message- From: Jonathan Lang [mailto:[EMAIL PROTECTED] role A {has Cat $.x;} role B {has Dog $.x;} class Foo {does Cat; does Dog;} my Foo $bar; $bar.x; # Is this a Cat or a Dog? If, however, two roles try

RE: A12: Conflicting Attributes in Roles

2004-04-21 Thread Austin Hastings
> -Original Message- > From: Jonathan Lang [mailto:[EMAIL PROTECTED] > > role A {has Cat $.x;} > role B {has Dog $.x;} > class Foo {does Cat; does Dog;} > my Foo $bar; > $bar.x; # Is this a Cat or a Dog? If, however, two roles try to introduce a method of the same name (for some defini