1PPI::Token::Prototype(3U)ser Contributed Perl DocumentatiPoPnI::Token::Prototype(3)
2
3
4
6 PPI::Token::Prototype - A subroutine prototype descriptor
7
9 PPI::Token::End
10 isa PPI::Token
11 isa PPI::Element
12
14 sub ($@) prototype;
15
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 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
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
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 braces and any whitespace inside the pattern.
46
48 See the support section in the main module.
49
51 Adam Kennedy <adamk@cpan.org>
52
54 Copyright 2001 - 2011 Adam Kennedy.
55
56 This program is free software; you can redistribute it and/or modify it
57 under the same terms as Perl itself.
58
59 The full text of the license can be found in the LICENSE file included
60 with this module.
61
62
63
64perl v5.12.3 2011-02-26 PPI::Token::Prototype(3)