Acme-Signature-Arity

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


      * number of required scalar parameters

      * number of optional scalar parameters (probably because there are
      defaults)

      * a character representing the slurping behaviour, might be '@' or
      '%', or nothing (undef?) if it's just a fixed list of scalar
      parameters

    This can also throw exceptions. That should only happen if you give it
    something that isn't a coderef, or if internals change enough that the
    entirely-unjustified assumptions made by this module are somehow no
    longer valid. Maybe they never were in the first place.

 max_arity

    Takes a coderef, returns a number or undef.

    If the code uses signatures, this tells you how many parameters you
    could pass when calling before it complains - undef means unlimited.

lib/Acme/Signature/Arity.pm  view on Meta::CPAN


=item * number of required scalar parameters

=item * number of optional scalar parameters (probably because there are defaults)

=item * a character representing the slurping behaviour, might be '@' or '%', or nothing (undef?) if it's
just a fixed list of scalar parameters

=back

This can also throw exceptions. That should only happen if you give it something that isn't
a coderef, or if internals change enough that the entirely-unjustified assumptions made by
this module are somehow no longer valid. Maybe they never were in the first place.

=cut

sub arity ($code) {
    die 'only works on coderefs' unless ref($code) eq 'CODE';
    my $cv = B::svref_2object($code);
    die 'probably not a coderef' unless $cv->isa('B::CV');
    my $next = $cv->START->next;

lib/Acme/Signature/Arity.pod  view on Meta::CPAN


=item * number of required scalar parameters

=item * number of optional scalar parameters (probably because there are defaults)

=item * a character representing the slurping behaviour, might be '@' or '%', or nothing (undef?) if it's
just a fixed list of scalar parameters

=back

This can also throw exceptions. That should only happen if you give it something that isn't
a coderef, or if internals change enough that the entirely-unjustified assumptions made by
this module are somehow no longer valid. Maybe they never were in the first place.

=head2 max_arity

Takes a coderef, returns a number or C<undef>.

If the code uses signatures, this tells you how many parameters you could
pass when calling before it complains - C<undef> means unlimited.



( run in 0.238 second using v1.01-cache-2.11-cpan-496ff517765 )