Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Roles and Mix-ins?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Piers Cawley  
View profile  
 More options Jan 7 2004, 3:48 am
Newsgroups: perl.perl6.language
From: pdcaw...@bofh.org.uk (Piers Cawley)
Date: Wed, 07 Jan 2004 08:23:52 +0000
Local: Wed, Jan 7 2004 3:23 am
Subject: Re: Roles and Mix-ins?

"Joe Gottman" <jgott...@carolina.rr.com> writes:
> ----- Original Message -----
> From: "Luke Palmer" <fibon...@babylonia.flatirons.org>
> To: <perl6-langu...@perl.org>
> Sent: Tuesday, January 06, 2004 4:51 AM
> Subject: [perl] Re: Roles and Mix-ins?

>> 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.

>    How about something like
>         class Trog
>        does Dog {bark=>dogBark} does Tree {bark=>treeBark}
>        {...}

>     Then we could have code like
>       my Trog $foo = Trog.new();
>       my Dog $spot :=  $foo;
>       my Tree $willow := $foo;
>       $spot.bark(); # calls dogBark()
>       $willow.bark(); #calls treeBark()

>    This works better when Dog::bark and Tree::bark are both needed but they
> do different things.

I'm really not happy with the idea that simply using a typed variable
should change the way a method call on that variable is
dispatched. You seem to be saying that

     class Parent { override { "Parent" }}
     class Child is Parent { override { "Child" }}

     my $kid = Child.new;

     my Parent $dad := $kid;

     print $kid.override; # "Child"
     print $dad.override; # "Parent"

And down that road lies C++ and other insanity.

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.