Perl::...totypes(3pm)

πŸ“¦
version 1.0.4 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– 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 a use declaration 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 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