.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Kavorka 3pm" .TH Kavorka 3pm "2019-01-17" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Kavorka \- function signatures with the lure of the animal .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Kavorka; \& \& fun maxnum (Num @numbers) { \& my $max = shift @numbers; \& for (@numbers) { \& $max = $_ if $max < $_; \& } \& return $max; \& } \& \& my $biggest = maxnum(42, 3.14159, 666); .Ve .SH "STATUS" .IX Header "STATUS" Kavorka is still at a very early stage of development; there are likely to be many bugs that still need to be shaken out. Certain syntax features are a little odd and may need to be changed in incompatible ways. .SH "DESCRIPTION" .IX Header "DESCRIPTION" Kavorka provides \f(CW\*(C`fun\*(C'\fR and \f(CW\*(C`method\*(C'\fR keywords for declaring functions and methods. It uses Perl 5.14's keyword \s-1API,\s0 so should work more reliably than source filters or Devel::Declare\-based modules. .PP The syntax provided by Kavorka is largely inspired by Perl 6, though it has also been greatly influenced by Method::Signatures and Function::Parameters. .PP For information using the keywords exported by Kavorka: .IP "\(bu" 4 Kavorka::Manual::Functions .IP "\(bu" 4 Kavorka::Manual::Methods .IP "\(bu" 4 Kavorka::Manual::MethodModifiers .IP "\(bu" 4 Kavorka::Manual::MultiSubs .SS "Exports" .IX Subsection "Exports" .ie n .IP """\-default""" 4 .el .IP "\f(CW\-default\fR" 4 .IX Item "-default" Exports \f(CW\*(C`fun\*(C'\fR and \f(CW\*(C`method\*(C'\fR. .ie n .IP """\-modifiers""" 4 .el .IP "\f(CW\-modifiers\fR" 4 .IX Item "-modifiers" Exports \f(CW\*(C`before\*(C'\fR, \f(CW\*(C`after\*(C'\fR, and \f(CW\*(C`around\*(C'\fR. .ie n .IP """\-allmodifiers""" 4 .el .IP "\f(CW\-allmodifiers\fR" 4 .IX Item "-allmodifiers" Exports \f(CW\*(C`before\*(C'\fR, \f(CW\*(C`after\*(C'\fR, \f(CW\*(C`around\*(C'\fR, \f(CW\*(C`augment\*(C'\fR, and \f(CW\*(C`override\*(C'\fR. .ie n .IP """\-all""" 4 .el .IP "\f(CW\-all\fR" 4 .IX Item "-all" Exports \f(CW\*(C`fun\*(C'\fR, \f(CW\*(C`method\*(C'\fR, \f(CW\*(C`before\*(C'\fR, \f(CW\*(C`after\*(C'\fR, \f(CW\*(C`around\*(C'\fR, \&\f(CW\*(C`augment\*(C'\fR, \f(CW\*(C`override\*(C'\fR, \f(CW\*(C`classmethod\*(C'\fR, \f(CW\*(C`objectmethod\*(C'\fR, and \f(CW\*(C`multi\*(C'\fR. .PP For example: .PP .Vb 2 \& # Everything except objectmethod and multi... \& use Kavorka qw( \-default \-allmodifiers classmethod ); .Ve .PP You can rename imported functions: .PP .Vb 1 \& use Kavorka method => { \-as => \*(Aqmeth\*(Aq }; .Ve .PP You can provide alternative implementations: .PP .Vb 2 \& # use My::Sub::Method instead of Kavorka::Sub::Method \& use Kavorka method => { implementation => \*(AqMy::Sub::Method\*(Aq }; .Ve .PP Or add traits to the default implementation: .PP .Vb 1 \& use Kavorka method => { traits => [\*(AqMy::Sub::Role::Foo\*(Aq] }; .Ve .PP See Exporter::Tiny for more tips. .SS "Function Introspection \s-1API\s0" .IX Subsection "Function Introspection API" The coderef for any sub created by Kavorka can be passed to the \&\f(CW\*(C`Kavorka\->info\*(C'\fR method. This returns a blessed object that does the Kavorka::Sub role. .PP .Vb 1 \& fun foo (:$x, :$y) { } \& \& my $info = Kavorka\->info(\e&foo); \& \& my $function_name = $info\->qualified_name; \& my @named_params = $info\->signature\->named_params; \& \& say $named_params[0]\->named_names\->[0]; # says \*(Aqx\*(Aq .Ve .PP See Kavorka::Sub, Kavorka::Signature and Kavorka::Parameter for further details. .PP If you're using Moose, consider using MooseX::KavorkaInfo to expose Kavorka method signatures via the meta object protocol. .PP Kavorka::Manual::API provides more details and examples using the introspection \s-1API.\s0 .SH "CAVEATS" .IX Header "CAVEATS" .IP "\(bu" 4 As noted in Kavorka::Manual::PrototypeAndAttributes, subroutine attributes don't work properly for anonymous functions. .IP "\(bu" 4 This module is based on Parse::Keyword, which has a chronically broken implementation of closures. Kavorka uses PadWalker to attempt to work around the problem. This mostly seems to work, but you may experience some problems in edge cases, especially for anonymous functions and methods. .IP "\(bu" 4 If importing Kavorka's method modifiers into Moo/Mouse/Moose classes, pay attention to load order: .Sp .Vb 2 \& use Moose; \& use Kavorka \-all; # ok .Ve .Sp If you do it this way, Moose's \f(CW\*(C`before\*(C'\fR, \f(CW\*(C`after\*(C'\fR, and \f(CW\*(C`around\*(C'\fR keywords will stomp on top of Kavorka's... .Sp .Vb 2 \& use Kavorka \-all; \& use Moose; # STOMP, STOMP, STOMP! :\-( .Ve .Sp This can lead to delightfully hard to debug errors. .SH "BUGS" .IX Header "BUGS" If seeing test failures on threaded Perl 5.21+, it may be a bug in Devel::CallParser 0.002. Try installing Alt::Devel::CallParser::ButWorking. .PP Please report any other bugs to . .SH "SUPPORT" .IX Header "SUPPORT" \&\fB\s-1IRC:\s0\fR support is available through in the \fI#moops\fR channel on irc.perl.org . .SH "SEE ALSO" .IX Header "SEE ALSO" Kavorka::Manual. .PP \&\fBInspirations:\fR , Function::Parameters, Method::Signatures. .PP . .SH "AUTHOR" .IX Header "AUTHOR" Toby Inkster . .SH "COPYRIGHT AND LICENCE" .IX Header "COPYRIGHT AND LICENCE" This software is copyright (c) 2013\-2014, 2017 by Toby Inkster. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. .SH "DISCLAIMER OF WARRANTIES" .IX Header "DISCLAIMER OF WARRANTIES" \&\s-1THIS PACKAGE IS PROVIDED \*(L"AS IS\*(R" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.\s0