develooper Front page | perl.perl6.users | Postings from September 2018

Re: extending built-in classes

Thread Previous | Thread Next
Curt Tilmes
September 22, 2018 21:40
Re: extending built-in classes
Message ID:
On Sat, Sep 22, 2018 at 5:30 PM Larry Wall <> wrote:

> On Sat, Sep 22, 2018 at 11:40:13AM -0700, Joseph Brenner wrote:
> : Sounds good, thanks.
> Well, yes, *sounds* good.  :-)
> Monkey patching is allowed but discouraged in Perl 6, because Ruby.

Mixed in roles:
may be helpful as well.

You can add a role not just to a class, but to an instance of any other

my $x = "something";
say $x.WHAT;
role MyDebugRole { method mydebugthing { say "mydebugthing" } }
$x does MyDebugRole;
say $x.WHAT;


$x will totally act like it used to, but anywhere you like, now you can
call .mydebugthing() on it.

Pretty cool.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About