I still have several points unclear, this is my sample:
###################################
class Base {
    method toHash() {
        return {};
    }
}
role FooBar {
    has $.foo is rw;
    has $.bar is rw;
        toHash.wrap({
        my $hash = callsame();
        $hash<foo> = $self.foo;
        return $hash;
    });
}
class Compose is Base does FooBar {
}
my $obj = Compose.new(foo=>'foovalue', bar=>'barvalue');
my $data = $obj->toHash;###################################
1: It tells me "toHash" is not defined, as the role actually don't has that.
2: It seems that wrapping will affect the closure globally, but I only want 
class with specific role has specific modification.
> Date: Sun, 20 Jun 2010 13:53:59 +0200
> From: mor...@faui2k3.org
> To: jianding...@msn.com
> CC: perl6-users@perl.org
> Subject: Re: Two questions on Perl 6 functionality
> 
> 
> 
> Xi Yang wrote:
> > You might mis-understood method modifiers. I mean:
> > before x()
> > after x()
> > around x()
> > ....
> 
> In Perl 6, you do that with wrapping:
> 
> http://perlcabal.org/syn/S06.html#Wrapping
> 
> 
> Cheers,
> Moritz

                                          
                                          
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
https://signup.live.com/signup.aspx?id=60969

Reply via email to