Re: Magic v2 - Review for Merge and next steps

[email protected] ("Paul \"LeoNerd\" Evans")
Newsgroups perl.perl5.porters
Message-ID <[email protected]>
On Sat, 12 Jul 2025 15:06:00 +0100
"Paul \"LeoNerd\" Evans" <[email protected]> wrote:

> TL;DR: Please help review my "magic v2" so far so I can add more
> useful abilities that will provide a good foundation for implementing
> a whole bunch of features on top of.

...

> However, now that we can start considering things to look into
> bringing into development for (5.)43.1, I would like to propose the
> basic part of Magic v2 (the base mechanism with the ability to have
> different shapes), as well as the stable parts of scalar/array/hash
> variable magic. All of these are just neatened-up rewrites of existing
> behaviours, but made in a way as to allow a lot of extension in
> future.
> 
> Once these parts are merged, we'll be in a much better place to
> consider ability to add magic in other situations around subroutines,
> sub signature parameters, object fields, and a whole bunch of other
> places. Several of these overlap some existing PPC documents I have
> open, and would be a good step towards implementing them, so there's
> a lot that can be built on top of it.

It's taken me a bit longer to get to here than I originally intended,
but I'm now at a place where hopefully tomorrow I'll be able to make a
PR for phase 1 of this set of changes. ((I don't quite have it ready
now as I'm still in the process of writing a lot of the documentation
that should go alongside it, but I'm hoping tomorrow to have this
finished)).

Phase 1 simply adds the concept of "v2" magic, allowing just the things
that MAGIC already does, but in a neater way. It doesn't yet add any
new shapes of things, nor does it adjust any existing MAGIC code into
using it. But I think it's ready to have a look at, in the hope of
getting that phase 1 in before 5.44.

Phase 2 will then follow up by applying lots of small changes, each
rewriting one bit of core code that currently uses (v1) MAGIC into
Magic v2. Any or all of these are technically optional - they don't
really provide any fundamentally new ability or improvement, they're
all just there to demonstrate "Hey, this Magic v2 thing is nicer than
v1".

Once we get Phase 1 in we'll also be in a much better position to start
considering actually-new kinds of Magic in new situations, that can't
be done right now with v1. Such ideas as:

  * Subroutine magic, that is able to interrupt various times of the
    life of a subroutine to do with compiling its optree or running it.
    These will interact well with my "attributes-v2" abilities.

  * Pad variable magic, that is able to apply new abilities to lexical
    variables, object fields, and so on. Likewise, "attributes-v2" will
    also benefit from having these.

  * Scalar value magic, that is able to create viral "attached to the
    value" behaviours for attaching extra information or applying
    behaviours like security policies, user-defined tainting rules, and
    the like.

-- 
Paul "LeoNerd" Evans

[email protected]
http://www.leonerd.org.uk/  |  https://metacpan.org/author/PEVANS
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.