Acme-Signature-Arity
view release on metacpan or search on metacpan
you have. You must make sure that they, too, receive or can get the
source code. And you must tell them their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any program or other work which
contains a notice placed by the copyright holder saying it may be
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions. You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.
7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
cost, duplication charges, time of people involved, and so on. (You will
not be required to justify it to the Copyright Holder, but only to the
computing community at large as a market that must bear the fee.)
- "Freely Available" means that no fee is charged for the item itself, though
there may be fees involved in handling the item. It also means that
recipients of the item may redistribute it under the same conditions they
received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications derived
from the Public Domain or from the Copyright Holder. A Package modified in such
a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided that
you insert a prominent notice in each changed file stating how and when you
changed that file, and provided that you do at least ONE of the following:
a) place your modifications in the Public Domain or otherwise make them
Takes a coderef, returns a number or undef.
If the code uses signatures, this tells you how many parameters you
need to pass when calling - 0 means that no parameters are required.
Should also work when there are no signatures, returning 0 in that
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.
lib/Acme/Signature/Arity.pm view on Meta::CPAN
=cut
sub min_arity ($code) {
my ($scalars, $optional, $slurp) = arity($code);
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.
lib/Acme/Signature/Arity.pod view on Meta::CPAN
=encoding utf8
=for comment POD_DERIVED_INDEX_GENERATED
The following documentation is automatically generated. Please do not edit
this file, but rather the original, inline with Acme::Signature::Arity
at lib/Acme/Signature/Arity.pm
(on the system that originally ran this).
If you do edit this file, and don't want your changes to be removed, make
sure you change the first line.
=cut
=head1 NAME
Acme::Signature::Arity - provides reliable, production-ready signature introspection
=head1 DESCRIPTION
lib/Acme/Signature/Arity.pod view on Meta::CPAN
Takes a coderef, returns a number or C<undef>.
If the code uses signatures, this tells you how many parameters you need to
pass when calling - 0 means that no parameters are required.
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.
( run in 2.508 seconds using v1.01-cache-2.11-cpan-1c8d708658b )