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 proto‐
18       type is a lot more like a string. Its job is to provide hints to the
19       perl compiler on what type of arguments a particular subroutine
20       expects, which the compiler uses to validate parameters at com‐
21       pile-time, and allows programmers to use the functions without explicit
22       parameter braces.
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 func‐
27       tions.
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 { $_->sexy } @chicks ) {
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
45       The "prototype" accessor returns the actual prototype pattern, stripped
46       of braces and any whitespace inside the pattern.
47

SUPPORT

49       See the support section in the main module.
50

AUTHOR

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