thanks for the info Carl.  Unless you really have tight memory constraints,
I think this solution is fine.


Cheers,
Frank



On Mon, Mar 4, 2013 at 3:04 PM, Carl Mäsak <cma...@gmail.com> wrote:

> Frank (>>), Moritz (>):
> >> Hi, I am new to Perl6 and I'm interested in the feature that allows you
> to
> >> add roles to classes.  From what I understand you can add a role to an
> >> object using the "does" keyword.  Is there any way you can remove a
> role or
> >
> > No, you cannot remove roles.
>
> However, if you want an un-adorned object later, just use infix:<but>,
> and keep the original object around.
>
>     class C {
>        has $.name = "original";
>     }
>
>     role W {
>        method name { "wrapped" }
>     }
>
>     my $original = C.new;
>     {
>        my $wrapped = $original but W;
>        say $wrapped.name;  # "wrapped"
>        say $wrapped ~~ W;  # True
>     }
>     say $original.name;  # "original"
>     say $original ~~ W;  # False
>
> // Carl
>

Reply via email to