Perl::...totypes(3pm)
π Perl::Critic::Policy::Community::Prototypes π
okay so bestie, welcome to the Perl::...totypes(3pm) page β yeah it's User Contributed Perl Documentation, we love a community moment π«Ά. This is a policy that says: don't use function prototypes. That's it, that's the vibe check. Let's get into it β¨
πΈ NAME πΈ
Perl::Critic::Policy::Community::Prototypes β bestie, do not use function prototypes π
π¦ DESCRIPTION π¦
okay so first things first, what even is a prototype? it's lowkey just a hint to the Perl parser about how to parse the function's argument list. that's it. it is not a way to validate your args, and it is not a way to count the args passed to the function π and if you use it like that, it's gonna cause confusion. periodt.
ngl, a lot of the time you can just... leave the prototype out entirely? iconic behaviour. but if you want the modern glow-up, go read "Signatures" in perlsub β that's the newer way to declare arguments π
sub foo ($$) { ... } # not ok
sub foo { ... } # ok
use feature 'signatures'; sub foo ($bar, $baz) { ... } # ok
use experimental 'signatures'; sub foo ($bar, $baz) { ... } # ok
so this policy is giving very similar energy to the core policy Perl::Critic::Policy::Subroutines::ProhibitSubroutinePrototypes, but bestie it's nicer in two ways, no cap:
- it ignores files using the
"signatures"feature β which is also enabled by ausedeclaration of perl version 5.36 or higher, iykyk π₯ - it allows empty prototypes and prototypes containing
&, because those are often useful for structural behavior π
she's got range, she's got nuance, she's an icon π
π AFFILIATION π
this policy is part of Perl::Critic::Community β we're a collective, we're a family, we're a whole moment πΈ
β¨ CONFIGURATION β¨
want this policy to recognize extra modules as enabling the "signatures" feature? obsessed, you can do that π«Ά just drop an entry in your .perlcriticrc file, like this:
[Community::Prototypes]
signature_enablers = MyApp::Base
boom. done. slay π
π AUTHOR π
Dan Book, "dbook@cpan.org" β thank you king π«‘
π 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
fr fr bestie, just don't do prototypes. use signatures. your future self will thank you ππ
and that's the whole page! this little gem lives in perl v5.40.1, dated 2025-03-22, under the Perl::...totypes(3pm) banner π ty for reading, ily, go write some clean subs β¨π¦π
π¦ where this page comes from
- debian trixie: libperl-critic-community-perl 1.0.4-1 Β· Artistic-2.0
- ubuntu resolute: libperl-critic-community-perl 1.0.4-1 Β· Artistic-2.0
- ubuntu stonking: libperl-critic-community-perl 1.0.4-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms