logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

PPI::Token::Prototype - A subroutine prototype descriptor

Author

       Adam Kennedy <adamk@cpan.org>

Description

       Although it sort of looks like a list or condition, a subroutine prototype is a lot more like a string.
       Its job is to provide hints to the perl compiler on what type of arguments a particular subroutine
       expects, which the compiler uses to validate parameters at compile-time, and allows programmers to use
       the functions without explicit parameter parens.

       Due to the rise of OO Perl coding, which ignores these prototypes, they are most often used to allow for
       constant-like things, and to "extend" the language and create things that act like keywords and core
       functions.

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

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

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

Inheritance

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

Methods

       This class provides one additional method beyond those defined by the PPI::Token and PPI::Element parent
       classes.

   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.

Name

       PPI::Token::Prototype - A subroutine prototype descriptor

Support

       See the support section in the main module.

Synopsis

         sub ($@) prototype;

See Also