1PPI::Token::Prototype(3U)ser Contributed Perl DocumentatiPoPnI::Token::Prototype(3)
2
3
4

NAME

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

INHERITANCE

9         PPI::Token::End
10         isa PPI::Token
11             isa PPI::Element
12

SYNOPSIS

14         sub ($@) prototype;
15

DESCRIPTION

17       Although it sort of looks like a list or condition, a subroutine
18       prototype is a lot more like a string. Its job is to provide hints to
19       the perl compiler on what type of arguments a particular subroutine
20       expects, which the compiler uses to validate parameters at compile-
21       time, and allows programmers to use the functions without explicit
22       parameter parens.
23
24       Due to the rise of OO Perl coding, which ignores these prototypes, they
25       are most often used to allow for constant-like things, and to "extend"
26       the language and create things that act like keywords and core
27       functions.
28
29         # Create something that acts like a constant
30         sub MYCONSTANT () { 10 }
31
32         # Create the "any" core-looking function
33         sub any (&@) { ... }
34
35         if ( any { $_->cute } @babies ) {
36               ...
37         }
38

METHODS

40       This class provides one additional method beyond those defined by the
41       PPI::Token and PPI::Element parent classes.
42
43   prototype
44       The "prototype" accessor returns the actual prototype pattern, stripped
45       of flanking parens and of all whitespace. This mirrors the behavior of
46       the Perl "prototype" builtin function.
47
48       Note that stripping parens and whitespace means that the return of
49       "prototype" can be an empty string.
50

SUPPORT

52       See the support section in the main module.
53

AUTHOR

55       Adam Kennedy <adamk@cpan.org>
56
58       Copyright 2001 - 2011 Adam Kennedy.
59
60       This program is free software; you can redistribute it and/or modify it
61       under the same terms as Perl itself.
62
63       The full text of the license can be found in the LICENSE file included
64       with this module.
65
66
67
68perl v5.34.0                      2022-02-02          PPI::Token::Prototype(3)
Impressum