develooper Front page | perl.perl5.porters | Postings from September 2022

Metaprogramming RFC - an update

Thread Next
Paul "LeoNerd" Evans
September 21, 2022 14:17
Metaprogramming RFC - an update
Message ID:
I've now been making a start at writing this.

As I write it, I find that actually a nicer design is not so much to
have lots of functions, but to have a few functions that return
"meta-objects"; in the style of Package::Stash or Object::Pad::MOP::*.
Even there's some similar sort of precedent in B.

Of the list I originally wrote, there's actually further things that
don't quite fit this pattern so far:

  * Interacting with the compiler while it compiles code; for example
    to inject callbacks at various occasions
      -- as per B::Hooks::EndOfScope
      -- as per B::CompilerPhase::Hook

so I shall leave those out.

In addition, for the section where I mentioned lexicals of functions,
it seems that there's a complex set of possible ideas in there but not
much actual use-case yet around core for providing anything specific:

  * Inspecting and manipulating lexicals captured by functions and
      -- as per PadWalker

I think for now I will omit both of these, and focus on the more basic
"symbols in packages" areas.

While I am there though there's a bunch of new ideas that do seem like
a good fit. All four functions of Sub::Util would be nice as simple
methods on a meta-subroutine object. In addition, there's a number of
patterns of code that tries to inspect various details using B, which
can be made into a much neater API shape on meta instead.

I hope to have a first cut at a draft by the end of the week. It's by
no means "ready", it has several open questions. But it serves as a
good start for further discussions.

Paul "LeoNerd" Evans      |  |

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