In perl.git, the branch abigail/deprecation has been updated <http://perl5.git.perl.org/perl.git/commitdiff/036a50fb04243a9659d226ce15c660997b063915?hp=696beaa76ccb4be5469e94d2fa26128e155efed1>
- Log ----------------------------------------------------------------- commit 036a50fb04243a9659d226ce15c660997b063915 Author: Abigail <[email protected]> Date: Sun Jan 15 22:23:47 2017 +0100 Use of $* and $# will be fatal in 5.30. Initially, the plan was to just drop the deprecation message of $* and $#, letting them be the magicless punctuation variables they are now. However, we decided to make their use fatal, so we can use them in a future version of Perl. M gv.c M pod/perldeprecation.pod M pod/perldiag.pod M t/lib/warnings/2use M t/lib/warnings/gv commit c9f19f02ab08d594b54cb9a142a3cb8bf46ca4cf Author: Abigail <[email protected]> Date: Sun Jan 15 13:23:34 2017 +0100 Revert "Remove deprecation warnings related to $* and $#." This reverts commit e9b5346b919b4f4cc0096af4644cb0d48d64e14c. We've decided that instead of leaving $* and $# as usuable, magic-free variables, we instead make it fatal to use them. Therefore, we restore the warnings their use gives, and in a subsequent commit, we fix the warning to indicate the version where their use becomes fatal. M gv.c M pod/perldeprecation.pod M pod/perldiag.pod M t/lib/warnings/2use M t/lib/warnings/gv commit 9184650838c327bb9ce738ffcf08b8acd44a74f9 Author: Abigail <[email protected]> Date: Sun Jan 15 13:23:12 2017 +0100 Revert "Fix mentioning of C<$#>." This reverts commit b9a643355baa0bd9bc9b4e9cbaf51c8727589bfa. M pod/perldeprecation.pod ----------------------------------------------------------------------- Summary of changes: gv.c | 16 +++++++++++++ pod/perldeprecation.pod | 56 +++++++++++++++++++-------------------------- pod/perldiag.pod | 22 ++++++++++++++++++ t/lib/warnings/2use | 20 ++++++++--------- t/lib/warnings/gv | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 130 insertions(+), 44 deletions(-) diff --git a/gv.c b/gv.c index a948234acd..99f9bcbebc 100644 --- a/gv.c +++ b/gv.c @@ -2151,6 +2151,14 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, SvREADONLY_on(av); } break; + case '*': /* $* */ + case '#': /* $# */ + if (sv_type == SVt_PV) + /* diag_listed_as: $* is no longer supported. Its use will be fatal in Perl 5.30 */ + Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX), + "$%c is no longer supported. Its use " + "will be fatal in Perl 5.30", *name); + break; case '\010': /* $^H */ { HV *const hv = GvHVn(gv); @@ -2257,6 +2265,14 @@ S_maybe_multimagic_gv(pTHX_ GV *gv, const char *name, const svtype sv_type) require_tie_mod_s(gv, '!', "Errno", 1); else if (*name == '-' || *name == '+') require_tie_mod_s(gv, *name, "Tie::Hash::NamedCapture", 0); + } else if (sv_type == SVt_PV) { + if (*name == '*' || *name == '#') { + /* diag_listed_as: $# is no longer supported. Its use will be fatal in Perl 5.30 */ + Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, + WARN_SYNTAX), + "$%c is no longer supported. Its use " + "will be fatal in Perl 5.30", *name); + } } if (sv_type==SVt_PV || sv_type==SVt_PVGV) { switch (*name) { diff --git a/pod/perldeprecation.pod b/pod/perldeprecation.pod index 31c9b57739..bb69f7f1f9 100644 --- a/pod/perldeprecation.pod +++ b/pod/perldeprecation.pod @@ -52,6 +52,29 @@ This usage has been deprecated, and will no longer be allowed in Perl 5.32. =head2 Perl 5.30 +=head3 C<< $* >> is no longer supported + +Before Perl 5.10, setting C<< $* >> to a true value globally enabled +multi-line matching within a string. This relique from the past lost +its special meaning in 5.10. Use of this variable will be a fatal error +in Perl 5.30, freeing the variable up for a future special meaning. + +To enable multiline matching one should use the C<< /m >> regexp +modifier (possibly in combination with C<< /s >>). This can be set +on a per match bases, or can be enabled per lexical scope (including +a whole file) with C<< use re '/m' >>. + +=head3 C<< $# >> is no longer supported + +This variable used to have a special meaning -- it could be used +to control how numbers were formatted when printed. This seldom +used functionality was removed in Perl 5.10. In order to free up +the variable for a future special meaning, its use will be a fatal +error in Perl 5.30. + +To specify how numbers are formatted when printed, one is adviced +to use C<< printf >> or C<< sprintf >> instead. + =head3 C<< File::Glob::glob() >> will disappear C<< File::Glob >> has a function called C<< glob >>, which just calls @@ -423,39 +446,6 @@ To tie the handle, use C<tie *$scalar> (with an explicit asterisk). The same applies to C<tied *$scalar> and C<untie *$scalar>. -=head2 Perl 5.10 - -=head3 $* is no longer supported - -C<$*> was once a magic variable. C<$*> enabled or disabled -multi-line matching within a string. Deprecated since Perl 5.000, -its special meaning was removed in Perl 5.10. Aftwards, an -deprecation message was issued when using this variable; this message -was discontinued in Perl 5.26. - -Instead of using C<$*> you should use the C</m> (and maybe C</s>) regexp -modifiers. You can enable C</m> for a lexical scope (even a whole file) -with C<use re '/m'>. (In older versions: when C<$*> was set to a true value -then all regular expressions behaved as if they were written using C</m>.) - -Although you can use C<$*> as a normal variable, you are discouraged -from doing so. - -=head3 $# is no longer supported - -C<$#> was once a magic variable. C<$#> could be used to format -printed numbers. Deprecated since Perl 5.000, -its special meaning was removed in Perl 5.10. Aftwards, an -deprecation message was issued when using this variable; this message -was discontinued in Perl 5.26. - -Instead of using C<$#>, you should be using C<(s)printf> to format -your numbers. - -Although you can use C<$#> as a normal variable, you are discouraged -from doing so. - - =head1 SEE ALSO L<warnings>, L<diagnostics>. diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 3bd8d304e9..d2e8297b51 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -3141,6 +3141,28 @@ You specified a character that has the given plainer way of writing it, and which is also portable to platforms running with different character sets. This usage is deprecated, and will be a fatal error in Perl 5.28. +=item $* is no longer supported. Its use will be fatal in Perl 5.30 + +(D deprecated, syntax) The special variable C<$*>, deprecated in older +perls, has been removed as of 5.10.0 and is no longer supported. In +previous versions of perl the use of C<$*> enabled or disabled multi-line +matching within a string. + +Instead of using C<$*> you should use the C</m> (and maybe C</s>) regexp +modifiers. You can enable C</m> for a lexical scope (even a whole file) +with C<use re '/m'>. (In older versions: when C<$*> was set to a true value +then all regular expressions behaved as if they were written using C</m>.) + +Use of this variable will be a fatal error in Perl 5.30. + +=item $# is no longer supported. Its use will be fatal in Perl 5.30 + +(D deprecated, syntax) The special variable C<$#>, deprecated in older +perls, has been removed as of 5.10.0 and is no longer supported. You +should use the printf/sprintf functions instead. + +Use of this variable will be a fatal error in Perl 5.30. + =item '%s' is not a code reference (W overload) The second (fourth, sixth, ...) argument of diff --git a/t/lib/warnings/2use b/t/lib/warnings/2use index ab5586a0a6..a02505eff1 100644 --- a/t/lib/warnings/2use +++ b/t/lib/warnings/2use @@ -361,21 +361,19 @@ Use of uninitialized value $c in scalar chop at - line 9. ######## # Check that deprecation warnings are not implicitly disabled by use -our $foo :unique; -use warnings "void"; -our $bar :unique; $*; +use warnings "void"; +$#; EXPECT -Attribute "unique" is deprecated, and will disappear in Perl 5.28 at - line 3. -Attribute "unique" is deprecated, and will disappear in Perl 5.28 at - line 5. -Useless use of a variable in void context at - line 6. +$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 3. +$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 5. +Useless use of a variable in void context at - line 5. ######## # Check that deprecation warnings are not implicitly disabled by no -our $foo :unique; -no warnings "void"; -our $bar :unique; $*; +no warnings "void"; +$#; EXPECT -Attribute "unique" is deprecated, and will disappear in Perl 5.28 at - line 3. -Attribute "unique" is deprecated, and will disappear in Perl 5.28 at - line 5. +$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 3. +$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 5. diff --git a/t/lib/warnings/gv b/t/lib/warnings/gv index 08a8474d4b..c8e2b89acd 100644 --- a/t/lib/warnings/gv +++ b/t/lib/warnings/gv @@ -59,6 +59,66 @@ EXPECT Use of inherited AUTOLOAD for non-method main::fáÆ() is deprecated. This will be fatal in Perl 5.28 at - line 7. ######## # gv.c +$a = ${"#"}; +$a = ${"*"}; +no warnings 'deprecated' ; +$a = ${"#"}; +$a = ${"*"}; +EXPECT +$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 2. +$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 3. +######## +# gv.c +$a = ${#}; +$a = ${*}; +no warnings 'deprecated' ; +$a = ${#}; +$a = ${*}; +EXPECT +$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 2. +$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 3. +######## +# gv.c +$a = $#; +$a = $*; +$# = $a; +$* = $a; +$a = \$#; +$a = \$*; +no warnings 'deprecated' ; +$a = $#; +$a = $*; +$# = $a; +$* = $a; +$a = \$#; +$a = \$*; +EXPECT +$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 2. +$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 3. +$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 4. +$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 5. +$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 6. +$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 7. +######## +# gv.c +@a = @#; +@a = @*; +$a = $#; +$a = $*; +EXPECT +$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 4. +$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 5. +######## +# gv.c +$a = $#; +$a = $*; +@a = @#; +@a = @*; +EXPECT +$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 2. +$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 3. +######## +# gv.c $a = ${^ENCODING}; $a = ${^E_NCODING}; ${^ENCODING} = 1; -- Perl5 Master Repository
