Perl::Critic::Policy::Community::Prototypes(3pm)

Perl::Critic::Policy::Community::Prototypes3pm

Don't use function prototypes

Overview

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

Releases

2 releases since Debian 12 (Bookworm); the text changed 1 time.

  1. 12
  2. 13

Author

Dan Book, "[email protected]"

From libperl-critic-community-perl 1.0.4-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.