PPI::To...rototype(3)

✨ NAME ✨

PPI::Token::Prototype β€” bestie, it's a subroutine prototype descriptor πŸ’…

Like, the manual page you're reading is PPI::To...rototype(3), and this class is the whole vibe.


πŸ¦‹ INHERITANCE πŸ¦‹

The family tree, no cap:

PPI::Token::Prototype
isa PPI::Token::Quote::Literal
    isa PPI::Token::Quote
        isa PPI::Token
            isa PPI::Element

So she's a PPI::Token::Quote::Literal at heart, which is a PPI::Token::Quote, which is a PPI::Token, which is a PPI::Element. Iconic lineage honestly πŸ‘‘


🌸 SYNOPSIS 🌸

sub ($@) prototype;

That's it. That's the whole moment ✨


πŸ’– DESCRIPTION πŸ’–

Okay so real talk: even though a subroutine prototype lowkey looks like a list or a condition, she is so much more like a string. Her whole job is giving hints to the perl compiler about what type of arguments a particular subroutine expects. The compiler then uses those hints to validate parameters at compile-time, and it also lets programmers call the functions without explicit parameter parens. Slay πŸ’…

Because OO Perl coding took over and OO Perl just ignores prototypes, these days prototypes are mostly used to allow for constant-like things, and to "extend" the language by creating things that act like keywords and core functions. Main character energy fr fr 🫢

# Create something that acts like a constant
sub MYCONSTANT () { 10 }

# Create the "any" core-looking function
sub any (&@) { ... }

if ( any { $_->cute } @babies ) {
      ...
}

πŸŽ€ METHODS πŸŽ€

This class provides one additional method beyond those defined by the PPI::Token and PPI::Element parent classes. Just the one. She's focused like that πŸ’œ

🌈 prototype

The "prototype" accessor returns the actual prototype pattern, stripped of flanking parens and of all whitespace. This mirrors the behavior of the Perl "prototype" builtin function.

Note that stripping parens and whitespace means that the return of "prototype" can be an empty string. Yes bestie, an empty string is a whole valid outcome 😭

πŸ“ SUPPORT πŸ“

See the support section in the main module. Go look, iykyk πŸ’–


πŸ‘‘ AUTHOR πŸ‘‘

Adam Kennedy <adamk@cpan.org>


Copyright 2001 - 2011 Adam Kennedy.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.


okay that's the whole page, bestie!! this was perl v5.42.0, dated 2026-01-17, and the manual page is PPI::To...rototype(3) πŸ¦‹βœ¨ mwah, go write some prototypes πŸ’…πŸŽ€

πŸ“¦ where this page comes from