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

Re: extending built-in classes

Thread Previous | Thread Next
From:
Joseph Brenner
Date:
September 22, 2018 18:40
Subject:
Re: extending built-in classes
Message ID:
CAFfgvXUuFRzg8pHazfbts_m4YiUvSj4NH-+F1FRFLFsKgK84YA@mail.gmail.com
Sounds good, thanks.

(I see the term is "augment"-- someone told me it was "extend", and I
couldn't find that anywhere.)


On Sat, Sep 22, 2018 at 11:35 AM, Brandon Allbery <allbery.b@gmail.com>
wrote:

> "use MONKEY-TYPING;" and then you have "augment" https://docs.perl6.
> org/syntax/augment.html
>
> On Sat, Sep 22, 2018 at 2:33 PM Joseph Brenner <doomvox@gmail.com> wrote:
>
>> I was just wondering if there's any way to extend an existing
>> class in perl 6.  I'd like to be able to do things like drop
>> a custom debugging method in Any that would then be available
>> on everything.
>>
>> Note: I'm talking about adding something to an existing class
>> ("monkeypatching") as opposed to subclassing.  In perl 5 land you
>> can just say "package Whatever;" again and re-open an existing
>> package.  With perl 6 saying "class Whatever" a second time would
>> be a "Redeclaration" error.
>>
>>
>>
>
> --
> brandon s allbery kf8nh
> allbery.b@gmail.com
>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About