summaryrefslogtreecommitdiff
path: root/pod/perlsub.pod
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2016-05-20 14:11:30 -0700
committerFather Chrysostomos <sprout@cpan.org>2016-05-20 15:59:57 -0700
commit06c4bad0551a71302ea93b2f015f632a62e48d76 (patch)
tree3ab5c39f299f278c94b494e505167d366ee93b22 /pod/perlsub.pod
parent32e7f215b3ed0d58db0abe1375ecbf0b202ddc43 (diff)
downloadperl-06c4bad0551a71302ea93b2f015f632a62e48d76.tar.gz
Update other docs on lexical sub acceptance
Diffstat (limited to 'pod/perlsub.pod')
-rw-r--r--pod/perlsub.pod23
1 files changed, 7 insertions, 16 deletions
diff --git a/pod/perlsub.pod b/pod/perlsub.pod
index 78de284733..a9daa8f6cb 100644
--- a/pod/perlsub.pod
+++ b/pod/perlsub.pod
@@ -1056,20 +1056,20 @@ using the CPAN module Sentinel or something similar.
=head2 Lexical Subroutines
X<my sub> X<state sub> X<our sub> X<subroutine, lexical>
-B<WARNING>: Lexical subroutines are still experimental. The feature may be
-modified or removed in future versions of Perl.
-
-Lexical subroutines are only available under the C<use feature
-'lexical_subs'> pragma, which produces a warning unless the
-"experimental::lexical_subs" warnings category is disabled.
-
Beginning with Perl 5.18, you can declare a private subroutine with C<my>
or C<state>. As with state variables, the C<state> keyword is only
available under C<use feature 'state'> or C<use 5.010> or higher.
+Prior to Perl 5.26, lexical subroutines were deemed experimental and were
+available only under the C<use feature 'lexical_subs'> pragma. They also
+produced a warning unless the "experimental::lexical_subs" warnings
+category was disabled.
+
These subroutines are only visible within the block in which they are
declared, and only after that declaration:
+ # Include these two lines if your code is intended to run under Perl
+ # versions earlier than 5.26.
no warnings "experimental::lexical_subs";
use feature 'lexical_subs';
@@ -1102,9 +1102,6 @@ containing block to the next.
So, in general, "state" subroutines are faster. But "my" subs are
necessary if you want to create closures:
- no warnings "experimental::lexical_subs";
- use feature 'lexical_subs';
-
sub whatever {
my $x = shift;
my sub inner {
@@ -1125,9 +1122,6 @@ subroutine of the same name.
The two main uses for this are to switch back to using the package sub
inside an inner scope:
- no warnings "experimental::lexical_subs";
- use feature 'lexical_subs';
-
sub foo { ... }
sub bar {
@@ -1143,9 +1137,6 @@ and to make a subroutine visible to other packages in the same scope:
package MySneakyModule;
- no warnings "experimental::lexical_subs";
- use feature 'lexical_subs';
-
our sub do_something { ... }
sub do_something_with_caller {