As part of PP0022, the metaprogramming API, I've uploaded a new
version of the `meta` module to CPAN:
https://metacpan.org/pod/meta
I've also started using it in a few modules, notably my various
Syntax::Operator::* modules, for implementing symbol export at `use`
time. As an example, here's a change that was made:
- no strict 'refs';
- $on ? *{"${caller}::$_"} = \&{$_}
+ $callerpkg //= meta::get_package( $caller );
+
+ $on ? $callerpkg->add_symbol( '&'.$_ => \&{$_} )
I'll gradually go around more of my modules, looking for more places
where `no strict 'refs'` currently appears and replace them with some
nicer code based on `meta`.
The entire point of experimenting with this module on CPAN is to allow
us to get a good feel for what API shape is best, so it'd be really
useful in that regard if more folks could start to make use of this and
test it out in a variety of situations. I'd love to receive more
feedback on what new bits of API need adding, or what changes to make
to things already there.
Once this becomes a bit more battle-tested and stable the module will
become a core-supplied dual-life one, but before that happens we need
more folks testing it out.
Thanks,
SEE ALSO
https://github.com/Perl/PPCs/blob/main/ppcs/ppc0022-metaprogramming.md
--
Paul "LeoNerd" Evans
leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
version of the `meta` module to CPAN:
https://metacpan.org/pod/meta
I've also started using it in a few modules, notably my various
Syntax::Operator::* modules, for implementing symbol export at `use`
time. As an example, here's a change that was made:
- no strict 'refs';
- $on ? *{"${caller}::$_"} = \&{$_}
+ $callerpkg //= meta::get_package( $caller );
+
+ $on ? $callerpkg->add_symbol( '&'.$_ => \&{$_} )
I'll gradually go around more of my modules, looking for more places
where `no strict 'refs'` currently appears and replace them with some
nicer code based on `meta`.
The entire point of experimenting with this module on CPAN is to allow
us to get a good feel for what API shape is best, so it'd be really
useful in that regard if more folks could start to make use of this and
test it out in a variety of situations. I'd love to receive more
feedback on what new bits of API need adding, or what changes to make
to things already there.
Once this becomes a bit more battle-tested and stable the module will
become a core-supplied dual-life one, but before that happens we need
more folks testing it out.
Thanks,
SEE ALSO
https://github.com/Perl/PPCs/blob/main/ppcs/ppc0022-metaprogramming.md
--
Paul "LeoNerd" Evans
leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/