table of contents
Perl::Critic::Policy::Community::Prototypes(3pm) | User Contributed Perl Documentation | Perl::Critic::Policy::Community::Prototypes(3pm) |
NAME¶
Perl::Critic::Policy::Community::Prototypes - Don't use function prototypes
DESCRIPTION¶
Function prototypes are primarily a hint to the Perl parser for parsing the function's argument list. They are not a way to validate or count the arguments passed to the function, and will cause confusion if used this way. Often, the prototype can simply be left out, but see "Signatures" in perlsub for a more modern method of declaring arguments.
sub foo ($$) { ... } # not ok sub foo { ... } # ok use feature 'signatures'; sub foo ($bar, $baz) { ... } # ok use experimental 'signatures'; sub foo ($bar, $baz) { ... } # ok
This policy is similar to the core policy Perl::Critic::Policy::Subroutines::ProhibitSubroutinePrototypes, but additionally ignores files using the "signatures" feature (which is also enabled by a "use" declaration of perl version 5.36 or higher), and allows empty prototypes and prototypes containing "&", as these are often useful for structural behavior.
AFFILIATION¶
This policy is part of Perl::Critic::Community.
CONFIGURATION¶
This policy can be configured to recognize additional modules as enabling the "signatures" feature, by putting an entry in a ".perlcriticrc" file like this:
[Community::Prototypes] signature_enablers = MyApp::Base
AUTHOR¶
Dan Book, "dbook@cpan.org"
COPYRIGHT AND LICENSE¶
Copyright 2015, Dan Book.
This library is free software; you may redistribute it and/or modify it under the terms of the Artistic License version 2.0.
SEE ALSO¶
Perl::Critic
2022-07-25 | perl v5.40.0 |