develooper Front page | perl.perl5.porters | Postings from May 2016

Re: revert MG consting (Coro breakage) for 5.24?

From:
Leon Timmermans
Date:
May 4, 2016 15:48
Subject:
Re: revert MG consting (Coro breakage) for 5.24?
Message ID:
CAHhgV8h883imZ-mw3iLgjLy8Jst6SvP0WV9NYa_9uGoAvvJm_Q@mail.gmail.com
On Tue, May 3, 2016 at 10:22 PM, Paul "LeoNerd" Evans <
leonerd@leonerd.org.uk> wrote:

> It gives non-core CPAN module code the ability to mutate and change the
> inner workings of perl core.
>
> Isn't that what a lot of the more interesting hooks and features are
> for? I occasionally find myself wanting some hook or ability and get a
> little annoyed that there isn't one; but that's usually just down to
> insufficient foresight for someone to have added it, or considerations
> of the performance impact it would have (e.g. my desire to hook
> SvREFCNT_dec). Intentionally removing a hook that has been demonstrated
> to have use-cases seems a whole different thing.


For scalar magic, there is an easy enough alternative: you create a new
magic vtable, and redirect the vtable field to that. It's easy enough, and
scoped much more narrow than the global table.

For hashes and arrays, this turns out to be more complicated, mainly
because the magic of hashes and arrays is kind of bizarre. You first need
to modify the hash/array's magic, so it will cast your alternative magic on
its elements at the appropriate time so it does what you want it to do.

Leon



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