meta#
Meta-programming without symbolic references: objects for packages (meta::package), globs (meta::glob), variables (meta::variable), subroutines (meta::subroutine) and their signatures (meta::subsignature), with methods to look into them and change them - add and remove symbols, name a sub, set its prototype, read a signature’s parameters. Every function warns in the meta::experimental category.
This is a native implementation of meta 0.015’s meta.xs; its meta.pm is used unchanged.
Synopsis#
use meta;
no warnings 'meta::experimental';
my $pkg = meta::package->get("My::Class");
$pkg->add_symbol('&hello' => sub { "hello" });
print My::Class->hello, "\n";
my $sub = meta::package->get("main")->get_symbol('&handler');
print $sub->subname, "\n"; # main::handler
Each object is a reference to the address of what it describes, blessed into its class, as meta.xs makes them.
Modules#
Functions#
Packages#
get_package#
meta::get_package($name): the package $name, created if it does not exist.
get_this_package#
meta::get_this_package(): the package of the code that calls it.
Symbols#
for_reference#
meta::for_reference($ref): the glob, subroutine or variable $ref refers to; a non-reference croaks.