Acme-Signature-Arity
view release on metacpan or search on metacpan
case.
coderef_ignoring_extra
Given a coderef, returns a coderef (either the original or wrapped)
which won't complain if you try to pass more parameters than it was
expecting.
This is intended for library authors in situations like this:
$useful_library->each(sub ($item) { say "item here: $item" });
where you later want to add optional new parameters, and don't trust
your users to include the mandatory , @ signature definition that
indicates excess parameters can be dropped.
Usage - let's say your first library version looked like this:
sub each ($self, $callback) {
my $code = $callback;
for my $item ($self->{items}->@*) {
$code->($item);
}
}
and you later want to pass the index as an extra parameter, without
breaking existing code that assumed there would only ever be one
lib/Acme/Signature/Arity.pm view on Meta::CPAN
return $scalars - $optional;
}
=head2 coderef_ignoring_extra
Given a coderef, returns a coderef (either the original or wrapped)
which won't complain if you try to pass more parameters than it was expecting.
This is intended for library authors in situations like this:
$useful_library->each(sub ($item) { say "item here: $item" });
where you later want to add optional new parameters, and don't trust your users
to include the mandatory C<< , @ >> signature definition that indicates excess
parameters can be dropped.
Usage - let's say your first library version looked like this:
sub each ($self, $callback) {
my $code = $callback;
for my $item ($self->{items}->@*) {
$code->($item);
}
}
and you later want to pass the index as an extra parameter, without breaking existing code
that assumed there would only ever be one callback parameter...
lib/Acme/Signature/Arity.pod view on Meta::CPAN
Should also work when there are no signatures, returning 0 in that case.
=head2 coderef_ignoring_extra
Given a coderef, returns a coderef (either the original or wrapped)
which won't complain if you try to pass more parameters than it was expecting.
This is intended for library authors in situations like this:
$useful_library->each(sub ($item) { say "item here: $item" });
where you later want to add optional new parameters, and don't trust your users
to include the mandatory C<, @> signature definition that indicates excess
parameters can be dropped.
Usage - let's say your first library version looked like this:
sub each ($self, $callback) {
my $code = $callback;
for my $item ($self->{items}->@*) {
$code->($item);
}
}
and you later want to pass the index as an extra parameter, without breaking existing code
that assumed there would only ever be one callback parameter...
( run in 0.504 second using v1.01-cache-2.11-cpan-5511b514fd6 )