Skip to content

Commit

Permalink
Update other docs on lexical sub acceptance
Browse files Browse the repository at this point in the history
  • Loading branch information
Father Chrysostomos committed May 20, 2016
1 parent 32e7f21 commit 06c4bad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 28 deletions.
18 changes: 6 additions & 12 deletions pod/perlexperiment.pod
Expand Up @@ -46,18 +46,6 @@ See L<perlapi/PL_keyword_plugin> for the mechanism.

Introduced in Perl 5.11.2

=item Lexical subroutines

Introduced in Perl 5.18

See also: L<perlsub/Lexical Subroutines>

Using this feature triggers warnings in the category
C<experimental::lexical_subs>.

The ticket for this feature is
L<[perl #120085]|https://rt.perl.org/rt3/Ticket/Display.html?id=120085>.

=item Regular Expression Set Operations

Introduced in Perl 5.18
Expand Down Expand Up @@ -249,6 +237,12 @@ Introduced in Perl 5.20.0

Accepted in Perl 5.24.0

=item Lexical subroutines

Introduced in Perl 5.18.0

Accepted in Perl 5.26.0

=back

=head2 Removed features
Expand Down
23 changes: 7 additions & 16 deletions pod/perlsub.pod
Expand Up @@ -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';

Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 06c4bad

Please sign in to comment.