diff options
author | Peter Martini <PeterCMartini@GMail.com> | 2013-08-06 03:16:35 -0400 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-08-06 05:53:07 -0700 |
commit | eb40d2ca32bab47c140b354a1907b0ba5b74f9bc (patch) | |
tree | 926a5446502b2b60e6390b9e1b3c86a9c270150c /pod/perlsub.pod | |
parent | 51da40ed5ad9513dc5f2213b76a414e9eb4c239d (diff) | |
download | perl-eb40d2ca32bab47c140b354a1907b0ba5b74f9bc.tar.gz |
[perl #2726] Prototype is not applied until BLOCK is defined
In the case of a sub definition with a prototype, the prototype
is not attached to the sub until after the body is completely
defined. This means that any sub which calls itself will
not honor its prototype unless the prototype was declared prior to
the sub's definition. Whether or not this behavior is desirable is
debatable, but its far too late to do anything about it other than
document it and test to make sure it doesn't change.
Diffstat (limited to 'pod/perlsub.pod')
-rw-r--r-- | pod/perlsub.pod | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/pod/perlsub.pod b/pod/perlsub.pod index ff5feb5dc3..455fa2393a 100644 --- a/pod/perlsub.pod +++ b/pod/perlsub.pod @@ -1338,6 +1338,16 @@ C<func()> now gets passed in a C<1>; that is, the number of elements in C<@foo>. And the C<split> gets called in scalar context so it starts scribbling on your C<@_> parameter list. Ouch! +If a sub has both a PROTO and a BLOCK, the prototype is not applied +until after the BLOCK is completely defined. This means that a recursive +function with a prototype has to be predeclared for the prototype to take +effect, like so: + + sub foo($$); + sub foo($$) { + foo 1, 2; + } + This is all very powerful, of course, and should be used only in moderation to make the world a better place. |