Subject: | Definition callback |
Yet another wishlist item...
use Function::Parameters before => {
name => 'required',
shift => [qw( $self )],
check_argument_count => 1,
definition => sub {
my $info = shift; # Function::Parameters::Info
__PACKAGE__->meta->add_before_method_modifier(
$info->name,
$info->body,
);
},
};
The idea being that if the "before" keyword is created as above, then
this:
before foo () {
...;
}
Then rather than "before" actually creating a sub in the current
package, it passes the coderef, the name, etc to the definition
callback.
It still does all the shifting, argument checking, etc - the only thing
it leaves the definition callback to do is add the coderef to the
package's symbol table (or choose not to).