Kavorka::Signature(3pm)

NAME
Kavorka::Signature - a function signature

DESCRIPTION
Kavorka::Signature is a class where each instance represents a function signature. This class is used to parse the function signature, and also to inject Perl code into the final function.

Instances of this class are also returned by Kavorka's function introspection API.

  Introspection API
A signature instance has the following methods. Each method which returns parameters, returns an instance of Kavorka::Parameter.

"package"
    Returns the package name the parameter was declared in.

"params"
    Returns an arrayref of parameters.

"return_types"
    Returns an arrayref of declared return types.

"has_invocants", "invocants"
    Returns a boolean/list of invocant parameters.

"positional_params"
    Returns a list of positional parameters.

"has_named", "named_params"
    Returns a boolean/list of named parameters.

"has_slurpy", "slurpy"
    Returns a boolean indicating whether there is a slurpy parameter in this signature / returns the slurpy parameter.

"yadayada"
    Indicates whether the yadayada operator was encountered in the signature.

"last_position"
    The numeric index of the last positional parameter.

"args_min", "args_max"
    The minimum/maximum number of arguments expected by the function. Invocants are not counted. If there are any named or slurpy arguments, of the yada yada operator was used in the signature, then "args_max" will be undef.

"check(@args)"
    Check whether @args (which should include any invocants) would satisfy the signature.

"checker"
    Returns a coderef which acts like "check(@args)".

"inline_check($varname)"
    Returns a string of Perl code that acts like an inline check, given the name of an array variable, such as '@foo'.

  Other Methods

"parse"
    An internal method used to parse a signature. Only makes sense to use within a Parse::Keyword parser.

"parameter_class"
    A class to use for parameters when parsing the signature.

"return_type_class"
    A class to use for return types when parsing the signature.

"injection"
    The string of Perl code to inject for this signature.

"sanity_check"
    Tests that the signature is sane. (For example it would not be sane to have a slurpy parameter prior to a positional one.)

BUGS
Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=Kavorka>.

SEE ALSO
Kavorka::Manual::API, Kavorka::Sub, Kavorka::Parameter.

AUTHOR
Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE
This software is copyright (c) 2013-2014 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.