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: [email protected]
> To: [email protected]
> CC: [email protected]
> 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