Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.92k stars 549 forks source link

deprecate @*, %*, &*, ** too #12814

Closed p5pRT closed 7 years ago

p5pRT commented 11 years ago

Migrated from rt.perl.org#116943 (status was 'rejected')

Searchable as RT116943$

p5pRT commented 11 years ago

From @nwc10

perlvar says​:

  C\<$*> was a variable that you could use to enable multiline matching.   After a deprecation cycle\, its magic was removed in Perl v5.10.0.   Using it now triggers a warning​: C\<$* is no longer supported>.   You should use the C\ and C\ regexp modifiers instead.

This is true. In that currently a warning is issued​:

$ ./perl -e '$a = $*' $* is no longer supported at -e line 1.

However\, there's no such warning for other things in that typeglob.

$ ./perl -Ilib -e '@​* = ( "a"\, "b" ); print "\$*[1] is $*[1]\n"' $*[1] is b $ ./perl -Ilib -e '%* = ( "a"\, "b" ); print "\$*{a} is $*{a}\n"' $*{a} is b $ ./perl -Ilib -e '** = sub { print "Hello world\n" }; &*' Hello world

I think that we should deprecate the use of *all* of these. With the intent of freeing up the parser so that things like

  @​*array

can become meaningful in the near future. (Slurpy arrays and slurpy hashes would be particularly useful for signatures)

I've tried to use csearch to find instances of use of these constructions on CPAN\, but it's very hard to avoid getting a heck of a lot of output from unrelated things. As best I could work out (using a more restricted search term)\, they aren't used. I think that the biggest user may well be JAPHs and obfuscations relying on this​:

$ ./perl -Ilib -le 'print ******' 1

Nicholas Clark

p5pRT commented 11 years ago

From @tux

On Tue\, 26 Feb 2013 05​:41​:35 -0800\, Nicholas Clark (via RT) \perlbug\-followup@&#8203;perl\.org wrote​:

# New Ticket Created by Nicholas Clark # Please include the string​: [perl #116943] # in the subject line of all future correspondence about this issue. # \<URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=116943 >

perlvar says​:

C\<$\*> was a variable that you could use to enable multiline matching\.
After a deprecation cycle\, its magic was removed in Perl v5\.10\.0\.
Using it now triggers a warning&#8203;: C\<$\* is no longer supported>\.
You should use the C\</s> and C\</m> regexp modifiers instead\.

This is true. In that currently a warning is issued​:

$ ./perl -e '$a = $*' $* is no longer supported at -e line 1.

However\, there's no such warning for other things in that typeglob.

$ ./perl -Ilib -e '@​* = ( "a"\, "b" ); print "\$*[1] is $*[1]\n"' $*[1] is b $ ./perl -Ilib -e '%* = ( "a"\, "b" ); print "\$*{a} is $*{a}\n"' $*{a} is b $ ./perl -Ilib -e '** = sub { print "Hello world\n" }; &*' Hello world

I think that we should deprecate the use of *all* of these.

+1!

With the intent of freeing up the parser so that things like

@​*array

can become meaningful in the near future. (Slurpy arrays and slurpy hashes would be particularly useful for signatures)

I've tried to use csearch to find instances of use of these constructions on CPAN\, but it's very hard to avoid getting a heck of a lot of output from unrelated things. As best I could work out (using a more restricted search term)\, they aren't used. I think that the biggest user may well be JAPHs and obfuscations relying on this​:

$ ./perl -Ilib -le 'print ******' 1

Nicholas Clark

-- H.Merijn Brand http​://tux.nl Perl Monger http​://amsterdam.pm.org/ using perl5.00307 .. 5.17 porting perl5 on HP-UX\, AIX\, and openSUSE http​://mirrors.develooper.com/hpux/ http​://www.test-smoke.org/ http​://qa.perl.org http​://www.goldmark.org/jeff/stupid-disclaimers/

p5pRT commented 11 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 11 years ago

From @xdg

On Tue\, Feb 26\, 2013 at 9​:33 AM\, H.Merijn Brand \h\.m\.brand@&#8203;xs4all\.nl wrote​:

I think that we should deprecate the use of *all* of these.

+1!

+1

-- David Golden \xdg@&#8203;xdg\.me Take back your inbox! → http​://www.bunchmail.com/ Twitter/IRC​: @​xdg

p5pRT commented 11 years ago

From @rjbs

* Nicholas Clark \perlbug\-followup@&#8203;perl\.org [2013-02-26T08​:41​:35]

I think that we should deprecate the use of *all* of these.

As I've said off-list\, I am in favor.

-- rjbs

p5pRT commented 11 years ago

From @nwc10

On Tue\, Feb 26\, 2013 at 10​:10​:09AM -0500\, Ricardo Signes wrote​:

* Nicholas Clark \perlbug\-followup@&#8203;perl\.org [2013-02-26T08​:41​:35]

I think that we should deprecate the use of *all* of these.

As I've said off-list\, I am in favor.

Should we deprecate them in time for v5.18.0?

Nicholas Clark

p5pRT commented 11 years ago

From @tux

On Tue\, 26 Feb 2013 15​:53​:16 +0000\, Nicholas Clark \nick@&#8203;ccl4\.org wrote​:

On Tue\, Feb 26\, 2013 at 10​:10​:09AM -0500\, Ricardo Signes wrote​:

* Nicholas Clark \perlbug\-followup@&#8203;perl\.org [2013-02-26T08​:41​:35]

I think that we should deprecate the use of *all* of these.

As I've said off-list\, I am in favor.

Should we deprecate them in time for v5.18.0?

YES!

Nicholas Clark

-- H.Merijn Brand http​://tux.nl Perl Monger http​://amsterdam.pm.org/ using perl5.00307 .. 5.17 porting perl5 on HP-UX\, AIX\, and openSUSE http​://mirrors.develooper.com/hpux/ http​://www.test-smoke.org/ http​://qa.perl.org http​://www.goldmark.org/jeff/stupid-disclaimers/

p5pRT commented 11 years ago

From @rurban

On Tue\, Feb 26\, 2013 at 10​:11 AM\, H.Merijn Brand \h\.m\.brand@&#8203;xs4all\.nl wrote​:

On Tue\, 26 Feb 2013 15​:53​:16 +0000\, Nicholas Clark \nick@&#8203;ccl4\.org wrote​:

On Tue\, Feb 26\, 2013 at 10​:10​:09AM -0500\, Ricardo Signes wrote​:

* Nicholas Clark \perlbug\-followup@&#8203;perl\.org [2013-02-26T08​:41​:35]

I think that we should deprecate the use of *all* of these.

As I've said off-list\, I am in favor.

Should we deprecate them in time for v5.18.0?

Sure

-- Reini Urban http​://cpanel.net/ http​://www.perl-compiler.org/

p5pRT commented 11 years ago

From @rjbs

* Reini Urban \rurban@&#8203;x\-ray\.at [2013-02-26T11​:45​:23]

On Tue\, 26 Feb 2013 15​:53​:16 +0000\, Nicholas Clark \nick@&#8203;ccl4\.org wrote​:

Should we deprecate them in time for v5.18.0?

Sure

I'm with Reini.

-- rjbs

p5pRT commented 11 years ago

From @nwc10

Merged to blead\, so marking as resolved.

Nicholas Clark

p5pRT commented 11 years ago

@nwc10 - Status changed from 'open' to 'resolved'

p5pRT commented 11 years ago

From @cpansprout

On Thu Mar 21 04​:18​:24 2013\, nicholas wrote​:

Merged to blead\, so marking as resolved.

Hold on a moment.

$ ./perl -Ilib -e '**' ** is deprecated\, and will become a syntax error at -e line 1. $ ./perl -Ilib -e '*{*}' ** is deprecated\, and will become a syntax error at -e line 1. $ ./perl -Ilib -e '*{"*"}' ** is deprecated\, and will become a syntax error at -e line 1. $ ./perl -Ilib -e '$_ = "*"; *$_' ** is deprecated\, and will become a syntax error at -e line 1.

That is *not* good. If you want to deprecate \\\, then toke.c is the place to do it.

This close to a stable release\, I would suggest reverting it and reinstating the deprecation after 5.18.

(Yes\, I’ve been quiet lately\, but real life keeps getting in the way. Every time I think I’m going to have time\, it proves to be more elusive than I imagined. :-)

--

Father Chrysostomos

p5pRT commented 11 years ago

@nwc10 - Status changed from 'resolved' to 'open'

p5pRT commented 11 years ago

From @nwc10

On Sun\, Mar 24\, 2013 at 11​:46​:58AM -0700\, Father Chrysostomos via RT wrote​:

On Thu Mar 21 04​:18​:24 2013\, nicholas wrote​:

Merged to blead\, so marking as resolved.

Hold on a moment.

Sorry\, this reply took more than a moment.

$ ./perl -Ilib -e '**' ** is deprecated\, and will become a syntax error at -e line 1. $ ./perl -Ilib -e '*{*}' ** is deprecated\, and will become a syntax error at -e line 1. $ ./perl -Ilib -e '*{"*"}' ** is deprecated\, and will become a syntax error at -e line 1. $ ./perl -Ilib -e '$_ = "*"; *$_' ** is deprecated\, and will become a syntax error at -e line 1.

That is *not* good. If you want to deprecate \\\, then toke.c is the place to do it.

Yes\, you are right. (But there's more where I'm wrong\, below)

This close to a stable release\, I would suggest reverting it and reinstating the deprecation after 5.18.

I have done this all in a smoke-me branch. I think that it can be done in the tokeniser fairly simply in S_scan_ident(). It requires another parameter to state whether to warn on encountering "*"\, which is only true from the 4 points that call it to parse @​ & * %.

so​:

STATIC char * -S_scan_ident(pTHX_ char *s\, const char *send\, char *dest\, STRLEN destlen\, I32 ck_uni) +S_scan_ident(pTHX_ char *s\, const char *send\, char *dest\, STRLEN destlen\, + I32 ck_uni\, char warn_on_star) {   dVAR;   char *bracket = NULL; @​@​ -9318\,6 +9319\,10 @​@​ S_scan_ident(pTHX_ char *s\, const char *send\, char *dest\, STRLEN destlen\, I32 ck   if (s \< send   && (isIDFIRST_lazy_if(s\, is_utf8) || VALID_LEN_ONE_IDENT(s\, is_utf8)))   { + if (warn_on_star && !bracket && *s == '*') + Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED\, WARN_SYNTAX)\, + "%c* is deprecated\, and will become a syntax error"\, + warn_on_star);   if (is_utf8) {   const STRLEN skip = UTF8SKIP(s);   STRLEN i;

and 4 call sites like this​:

@​@​ -5647\,7 +5647\,7 @​@​ Perl_yylex(pTHX)

  case '*'​:   if (PL_expect != XOPERATOR) { - s = scan_ident(s\, PL_bufend\, PL_tokenbuf\, sizeof PL_tokenbuf\, TRUE); + s = scan_ident(s\, PL_bufend\, PL_tokenbuf\, sizeof PL_tokenbuf\, TRUE\, '*');   PL_expect = XOPERATOR;   force_ident(PL_tokenbuf\, '*');   if (!*PL_tokenbuf) @​@​ -5681\,7 +5681\,7 @​@​ Perl_yylex(pTHX)   }   PL_tokenbuf[0] = '%';   s = scan_ident(s\, PL_bufend\, PL_tokenbuf + 1\, - sizeof PL_tokenbuf - 1\, FALSE); + sizeof PL_tokenbuf - 1\, FALSE\, '%');   if (!PL_tokenbuf[1]) {   PREREF('%');   } @​@​ -6175\,7 +6175\,7 @​@​ Perl_yylex(pTHX)

  PL_tokenbuf[0] = '&';   s = scan_ident(s - 1\, PL_bufend\, PL_tokenbuf + 1\, - sizeof PL_tokenbuf - 1\, TRUE); + sizeof PL_tokenbuf - 1\, TRUE\, '&');   if (PL_tokenbuf[1]) {   PL_expect = XOPERATOR;   force_ident_maybe_lex('&'); @​@​ -6539\,7 +6539\,7 @​@​ Perl_yylex(pTHX)   if (PL_expect == XOPERATOR)   no_op("Array"\, s);   PL_tokenbuf[0] = '@​'; - s = scan_ident(s\, PL_bufend\, PL_tokenbuf + 1\, sizeof PL_tokenbuf - 1\, FALSE); + s = scan_ident(s\, PL_bufend\, PL_tokenbuf + 1\, sizeof PL_tokenbuf - 1\, FALSE\, '@​');   if (!PL_tokenbuf[1]) {   PREREF('@​');   }

However\, I think that I'm wrong on two further levels. I might be expressing these two in the wrong order​:

Firstly the intent was to enable syntax of the form @​*foo and %*bar.

Having @​*foo and %*bar would seem to imply that one can't also have @​* or %*.

What hadn't sunk is is that we have both $# and $#foo (and $#$foo)\, and there doesn't seem to be a parsing problem with this. There *is* some special casing for which punctuation vars $#... will work on\, notably only @​+\, @​- and @​@​​:

  if (s[1] == '#' && (isIDFIRST_lazy_if(s+2\,UTF) || strchr("{$​:+-@​"\, s[2]))) {   PL_tokenbuf[0] = '@​';

and\, unlike most of Perl 5\, recognising $#... is space sensitive​:

$ perl -le '$foo = [1..3]; $# = \*STDERR; print $#{$foo}' $# is no longer supported at -e line 1. 2 $ perl -le '$foo = "bar"; %# = (bar => "Baz"); $# = \*STDERR; print $# {$foo}' Baz

(in the latter\, $# {$foo} is a hash lookup for key $foo of hash %#)

but it generally works without surprising anyone.

As best I can figure out\, one could add @​*foo\, &*foo\, **foo\, %*foo $*foo without removing anything or breaking any sane code on CPAN. The only code which I think would change behaviour is that is either using $* as the variable for a file handle passed to print (anything else?)\, or code which would parse $*+=1 as $*+ = 1 instead of $* += 1\, or code which is making array slices on %*. (Attached are corner cases for $# parsing\, with equivalent examples showing that currently C\<$*> and C\<$* > are both parsed the same as C\<$# >.)

So I think that the right thing to do is not to blanket deprecate parsing @​* &* ** %* and $*\, but instead change the parser to warn or deprecate on the specific ambiguous constructions. Which means that the "new" "needed" constructions need to come first. Or at least some idea of them.

But\, I think I'm wrong again.

Secondly\, the specific intent was to have consistent "slurpy" syntax for subroutine signatures. Consistent with Perl 6\, and consistent between the Perl 5 signature and regular Perl 5 code.

And I got this wrong. In that\, Perl 6 does have @​*foo. But that's a dynamic scoping lookup. The slurpy syntax is *@​foo. (And *%foo\, and *$foo) http​://perlcabal.org/syn/S06.html#List_parameters

For which we don't need to worry about the various sigils used with the ** typeglob at all. We need to consider how the parser deals with the 3 typeglobs *@​\, *% and *$. And based on how $# and $#foo are handled\, I think that everything that is wanted for "new" syntax is currently a syntax error. Or\, if not\, all that is currently legal syntax is incredibly obscure corner cases.

Nicholas Clark

p5pRT commented 11 years ago

From @nwc10

$ perl -le '$foo = [1..3]; $# = \*STDERR; print $#{$foo}' $# is no longer supported at -e line 1. 2 $ perl -le '$foo = "bar"; %# = (bar => "Baz"); $# = \*STDERR; print $# {$foo}' Baz $ perl -le '$foo = "bar"; %* = (bar => "Baz"); $* = \*STDERR; print $* {$foo}' Baz $ perl -le '$foo = "bar"; %* = (bar => "Baz"); $* = \*STDERR; print $*{$foo}' Baz

$ perl -le '@​foo = (1..3); $# = \*STDERR; print $#{foo}' $# is no longer supported at -e line 1. 2 $ perl -le '%# = (foo => "bar"); $# = \*STDERR; print $# {foo}' bar $ perl -le '%* = (foo => "bar"); $* = \*STDERR; print $*{foo}' bar $ perl -le '%* = (foo => "bar"); $* = \*STDERR; print $* {foo}' bar

$ perl -le '$foo = [1..3]; $# = \*STDERR; print $#$foo'$# is no longer supported at -e line 1. 2 $ perl -le '$foo = [1..3]; $# = \*STDERR; print $# $foo' $# is no longer supported at -e line 1. ARRAY(0x100803ed0) $ perl -le '$foo = [1..3]; $* = \*STDERR; print $*$foo' $* is no longer supported at -e line 1. Scalar found where operator expected at -e line 1\, near "$*$foo"   (Missing operator before $foo?) ARRAY(0x100803ed0) $ perl -le '$foo = [1..3]; $* = \*STDERR; print $* $foo' $* is no longer supported at -e line 1. ARRAY(0x100803ed0)

$ ./perl -lwe '@​foo = (1..3); $# = \*STDERR; print $#​::foo' $# is no longer supported at -e line 1. 2 $ ./perl -lwe '@​foo = (1..3); $# = \*STDERR; print $# :​:foo' $# is no longer supported at -e line 1. $# is no longer supported at -e line 1. Bareword found where operator expected at -e line 1\, near "$# :​:foo"   (Missing operator before :​:foo?) :​:foo $ ./perl -lwe '@​foo = (1..3); $* = \*STDERR; print $*​::foo' $* is no longer supported at -e line 1. $* is no longer supported at -e line 1. Bareword found where operator expected at -e line 1\, near "$*​::foo"   (Missing operator before :​:foo?) Operator or semicolon missing before *​::foo at -e line 1. Ambiguous use of * resolved as operator * at -e line 1. :​:foo $ ./perl -lwe '@​foo = (1..3); $* = \*STDERR; print $* :​:foo' $* is no longer supported at -e line 1. $* is no longer supported at -e line 1. Bareword found where operator expected at -e line 1\, near "$* :​:foo"   (Missing operator before :​:foo?) :​:foo

$ perl -MO=Deparse -le '$#+=1' BEGIN { $/ = "\n"; $\ = "\n"; } $#+ = 1; -e syntax OK $ perl -MO=Deparse -le '$# +=1' $# is no longer supported at -e line 1. BEGIN { $/ = "\n"; $\ = "\n"; } $# += 1; -e syntax OK $ perl -MO=Deparse -le '$*+=1' $* is no longer supported at -e line 1. BEGIN { $/ = "\n"; $\ = "\n"; } $* += 1; -e syntax OK $ perl -MO=Deparse -le '$* +=1' $* is no longer supported at -e line 1. BEGIN { $/ = "\n"; $\ = "\n"; } $* += 1; -e syntax OK

# $#- is analagous to $#+\, and the assignments are run time errors

# Parsing of @​@​ and $#@​ was added by commit c0b977fd793319b0 in May 2009​:

perl5.14.0 -le '@​@​ = (1..7); @​; = (1..3); $# = \*STDERR; print $#@​;' $# is no longer supported at -e line 1. 6 perl5.14.0 -le '@​@​ = (1..7); @​; = (1..3); $# = \*STDERR; print $# @​;' $# is no longer supported at -e line 1. 123 perl5.14.0 -le '@​@​ = (1..7); @​; = (1..3); $* = \*STDERR; print $*@​;' $* is no longer supported at -e line 1. Array found where operator expected at -e line 1\, at end of line   (Missing operator before ?) 123 perl5.14.0 -le '@​@​ = (1..7); @​; = (1..3); $* = \*STDERR; print $* @​;' $* is no longer supported at -e line 1. 123

p5pRT commented 11 years ago

From @rjbs

From IRC\, lest it be lost​:

\<@​rjbs> Nicholas​: You asked whether we were okay to revert the imperfect deprecation. I said\, "I thought you already had!" \<@​rjbs> Nicholas​: ...but I think subsequent to that\, it has not actually been done\, and needs to be. Is that correct?

p5pRT commented 11 years ago

From @nwc10

On Tue\, Apr 30\, 2013 at 04​:14​:43PM -0700\, Ricardo SIGNES via RT wrote​:

From IRC\, lest it be lost​:

\<@​rjbs> Nicholas​: You asked whether we were okay to revert the imperfect deprecation. I said\, "I thought you already had!" \<@​rjbs> Nicholas​: ...but I think subsequent to that\, it has not actually been done\, and needs to be. Is that correct?

I've pushed the reversion to blead. To avoid it getting lost\, I've attached the other commit from that branch here before deleting it.

There are also two further commits with documentation and tests to apply after the code freeze in the branch smoke-me/nicholas/S_scan_ident

I keep thinking that there is something that I've missed here. Hence the delay. But if there is\, it hasn't come back to me after several weeks.

Nicholas Clark

p5pRT commented 11 years ago

From @nwc10

0001-Add-a-deprecation-warning-when-parsing-and.patch ```diff From e14d8621b18087e5a3854be4df8aa23b01b74dea Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Tue, 9 Apr 2013 15:54:25 +0200 Subject: [PATCH] Add a deprecation warning when parsing @*, %*, &* and **. Forms such as @{*}, @{"*"} are not deprecated, nor are runtime references to the variables, such as symbolic references or symbol table manipulation. --- embed.fnc | 2 +- embed.h | 2 +- pod/perldiag.pod | 7 +++++++ proto.h | 2 +- t/lib/warnings/gv | 34 ++++++++++++++++++++++++++++++++++ toke.c | 23 ++++++++++++++--------- 6 files changed, 58 insertions(+), 12 deletions(-) diff --git a/embed.fnc b/embed.fnc index ecdde73..9e34ccf 100644 --- a/embed.fnc +++ b/embed.fnc @@ -2199,7 +2199,7 @@ iR |SV* |get_and_check_backslash_N_name|NN const char* s \ sR |char* |scan_formline |NN char *s sR |char* |scan_heredoc |NN char *s s |char* |scan_ident |NN char *s|NN const char *send|NN char *dest \ - |STRLEN destlen|I32 ck_uni + |STRLEN destlen|I32 ck_uni|char warn_on_star sR |char* |scan_inputsymbol|NN char *start sR |char* |scan_pat |NN char *start|I32 type sR |char* |scan_str |NN char *start|int keep_quoted \ diff --git a/embed.h b/embed.h index 96309b2..a4e943e 100644 --- a/embed.h +++ b/embed.h @@ -1615,7 +1615,7 @@ #define scan_const(a) S_scan_const(aTHX_ a) #define scan_formline(a) S_scan_formline(aTHX_ a) #define scan_heredoc(a) S_scan_heredoc(aTHX_ a) -#define scan_ident(a,b,c,d,e) S_scan_ident(aTHX_ a,b,c,d,e) +#define scan_ident(a,b,c,d,e,f) S_scan_ident(aTHX_ a,b,c,d,e,f) #define scan_inputsymbol(a) S_scan_inputsymbol(aTHX_ a) #define scan_pat(a,b) S_scan_pat(aTHX_ a,b) #define scan_str(a,b,c,d,e) S_scan_str(aTHX_ a,b,c,d,e) diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 3d8212e..8abdd09 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -2642,6 +2642,13 @@ modifiers. You can enable C for a lexical scope (even a whole file) with C. (In older versions: when C<$*> was set to a true value then all regular expressions behaved as if they were written using C.) +=item %c* is deprecated, and will become a syntax error + +(D deprecated, syntax) The punctuation variables C<@*>, C<&*>, C<**> and +C<%*> will be removed soon. In future such code will fail to compile with a +syntax error. Removing these variables along with C<$*> will permit future +syntax additions. + =item $# is no longer supported (D deprecated, syntax) The special variable C<$#>, deprecated in older diff --git a/proto.h b/proto.h index 59ecbc6..0795918 100644 --- a/proto.h +++ b/proto.h @@ -7300,7 +7300,7 @@ STATIC char* S_scan_heredoc(pTHX_ char *s) #define PERL_ARGS_ASSERT_SCAN_HEREDOC \ assert(s) -STATIC char* S_scan_ident(pTHX_ char *s, const char *send, char *dest, STRLEN destlen, I32 ck_uni) +STATIC char* S_scan_ident(pTHX_ char *s, const char *send, char *dest, STRLEN destlen, I32 ck_uni, char warn_on_star) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2) __attribute__nonnull__(pTHX_3); diff --git a/t/lib/warnings/gv b/t/lib/warnings/gv index 6b022e1..c28dfae 100644 --- a/t/lib/warnings/gv +++ b/t/lib/warnings/gv @@ -100,6 +100,7 @@ $* is no longer supported at - line 7. $a = $#; $a = $*; EXPECT +@* is deprecated, and will become a syntax error at - line 3. $# is no longer supported at - line 4. $* is no longer supported at - line 5. ######## @@ -111,6 +112,39 @@ $a = $*; EXPECT $# is no longer supported at - line 2. $* is no longer supported at - line 3. +@* is deprecated, and will become a syntax error at - line 5. +######## +# gv.c +$a = \@*; +$a = \&*; +$a = \**; +$a = \%*; +no warnings 'deprecated' ; +$a = \@*; +$a = \&*; +$a = \**; +$a = \%*; +EXPECT +@* is deprecated, and will become a syntax error at - line 2. +&* is deprecated, and will become a syntax error at - line 3. +** is deprecated, and will become a syntax error at - line 4. +%* is deprecated, and will become a syntax error at - line 5. +######## +# gv.c +# None of these should warn: +$a = \@{*}; +$a = \&{*}; +$a = \*{*}; +$a = \%{*}; +$a = \@{"*"}; +$a = \&{"*"}; +$a = \*{"*"}; +$a = \%{"*"}; +$_ = "*"; +$a = \@$_; +$a = \&$_; +$a = \*$_; +$a = \%$_; ######## # gv.c use warnings 'syntax' ; diff --git a/toke.c b/toke.c index d7b95ed..e6cb503 100644 --- a/toke.c +++ b/toke.c @@ -3870,7 +3870,7 @@ S_intuit_more(pTHX_ char *s) weight -= seen[un_char] * 10; if (isWORDCHAR_lazy_if(s+1,UTF)) { int len; - scan_ident(s, send, tmpbuf, sizeof tmpbuf, FALSE); + scan_ident(s, send, tmpbuf, sizeof tmpbuf, FALSE, 0); len = (int)strlen(tmpbuf); if (len > 1 && gv_fetchpvn_flags(tmpbuf, len, UTF ? SVf_UTF8 : 0, SVt_PV)) @@ -5656,7 +5656,7 @@ Perl_yylex(pTHX) case '*': if (PL_expect != XOPERATOR) { - s = scan_ident(s, PL_bufend, PL_tokenbuf, sizeof PL_tokenbuf, TRUE); + s = scan_ident(s, PL_bufend, PL_tokenbuf, sizeof PL_tokenbuf, TRUE, '*'); PL_expect = XOPERATOR; force_ident(PL_tokenbuf, '*'); if (!*PL_tokenbuf) @@ -5690,7 +5690,7 @@ Perl_yylex(pTHX) } PL_tokenbuf[0] = '%'; s = scan_ident(s, PL_bufend, PL_tokenbuf + 1, - sizeof PL_tokenbuf - 1, FALSE); + sizeof PL_tokenbuf - 1, FALSE, '%'); if (!PL_tokenbuf[1]) { PREREF('%'); } @@ -6184,7 +6184,7 @@ Perl_yylex(pTHX) PL_tokenbuf[0] = '&'; s = scan_ident(s - 1, PL_bufend, PL_tokenbuf + 1, - sizeof PL_tokenbuf - 1, TRUE); + sizeof PL_tokenbuf - 1, TRUE, '&'); if (PL_tokenbuf[1]) { PL_expect = XOPERATOR; force_ident_maybe_lex('&'); @@ -6417,7 +6417,7 @@ Perl_yylex(pTHX) if (s[1] == '#' && (isIDFIRST_lazy_if(s+2,UTF) || strchr("{$:+-@", s[2]))) { PL_tokenbuf[0] = '@'; s = scan_ident(s + 1, PL_bufend, PL_tokenbuf + 1, - sizeof PL_tokenbuf - 1, FALSE); + sizeof PL_tokenbuf - 1, FALSE, 0); if (PL_expect == XOPERATOR) no_op("Array length", s); if (!PL_tokenbuf[1]) @@ -6429,7 +6429,7 @@ Perl_yylex(pTHX) PL_tokenbuf[0] = '$'; s = scan_ident(s, PL_bufend, PL_tokenbuf + 1, - sizeof PL_tokenbuf - 1, FALSE); + sizeof PL_tokenbuf - 1, FALSE, 0); if (PL_expect == XOPERATOR) no_op("Scalar", s); if (!PL_tokenbuf[1]) { @@ -6548,7 +6548,7 @@ Perl_yylex(pTHX) if (PL_expect == XOPERATOR) no_op("Array", s); PL_tokenbuf[0] = '@'; - s = scan_ident(s, PL_bufend, PL_tokenbuf + 1, sizeof PL_tokenbuf - 1, FALSE); + s = scan_ident(s, PL_bufend, PL_tokenbuf + 1, sizeof PL_tokenbuf - 1, FALSE, '@'); if (!PL_tokenbuf[1]) { PREREF('@'); } @@ -7817,7 +7817,7 @@ Perl_yylex(pTHX) p = PEEKSPACE(p); if (isIDFIRST_lazy_if(p,UTF)) { p = scan_ident(p, PL_bufend, - PL_tokenbuf, sizeof PL_tokenbuf, TRUE); + PL_tokenbuf, sizeof PL_tokenbuf, TRUE, 0); p = PEEKSPACE(p); } if (*p != '$') @@ -9270,7 +9270,8 @@ S_scan_word(pTHX_ char *s, char *dest, STRLEN destlen, int allow_package, STRLEN } STATIC char * -S_scan_ident(pTHX_ char *s, const char *send, char *dest, STRLEN destlen, I32 ck_uni) +S_scan_ident(pTHX_ char *s, const char *send, char *dest, STRLEN destlen, + I32 ck_uni, char warn_on_star) { dVAR; char *bracket = NULL; @@ -9329,6 +9330,10 @@ S_scan_ident(pTHX_ char *s, const char *send, char *dest, STRLEN destlen, I32 ck if (s < send && (isIDFIRST_lazy_if(s, is_utf8) || VALID_LEN_ONE_IDENT(s, is_utf8))) { + if (warn_on_star && !bracket && *s == '*') + Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX), + "%c* is deprecated, and will become a syntax error", + warn_on_star); if (is_utf8) { const STRLEN skip = UTF8SKIP(s); STRLEN i; -- 1.7.2.5 ```
p5pRT commented 11 years ago

From @rjbs

Thanks\, unblocking.

-- rjbs

p5pRT commented 11 years ago

From @cpansprout

On Tue Apr 09 07​:33​:10 2013\, nicholas wrote​:

And I got this wrong. In that\, Perl 6 does have @​*foo. But that's a dynamic scoping lookup. The slurpy syntax is *@​foo. (And *%foo\, and *$foo) http​://perlcabal.org/syn/S06.html#List_parameters

For which we don't need to worry about the various sigils used with the ** typeglob at all. We need to consider how the parser deals with the 3 typeglobs *@​\, *% and *$. And based on how $# and $#foo are handled\, I think that everything that is wanted for "new" syntax is currently a syntax error. Or\, if not\, all that is currently legal syntax is incredibly obscure corner cases.

Not too incredibly​:

vec $buf\,1\,1\,*$foo

I take advantage of that comma-then-infix trick all the time.

And when generating reports\, multiplying by an array length (*@​foo) is not so uncommon\, either.

--

Father Chrysostomos

p5pRT commented 8 years ago

From @jkeenan

On Tue Feb 26 05​:41​:34 2013\, nicholas wrote​:

perlvar says​:

Dan Collins did some bookkeeping on this RT today\, which pushed it to the top of the sorted-by-last-modification date in the New queue\, which in turn brought it to my attention.

My recommendation is that we close this ticket and request that anyone who is interested in its subject matter submit a new ticket.

* There has been no discussion in the ticket in 3-1/4 years.

* When there was discussion\, there was (a) commits\, then reverts; (b) disagreement as to how to proceed. Consequently\, it's very difficult to understand what the current status of the ticket is.

I am taking this ticket for the purpose of closing it in 7 days unless someone takes it over and moves the discussion forward.

Thank you very much.

-- James E Keenan (jkeenan@​cpan.org)

p5pRT commented 8 years ago

From @cpansprout

On Fri Sep 30 12​:10​:27 2016\, jkeenan wrote​:

On Tue Feb 26 05​:41​:34 2013\, nicholas wrote​:

perlvar says​:

Dan Collins did some bookkeeping on this RT today\, which pushed it to the top of the sorted-by-last-modification date in the New queue\,

Oh\, so I’m not the only one doing that. :-)

which in turn brought it to my attention.

My recommendation is that we close this ticket

I agree.

--

Father Chrysostomos

p5pRT commented 7 years ago

From @jkeenan

On Fri Sep 30 12​:36​:39 2016\, sprout wrote​:

On Fri Sep 30 12​:10​:27 2016\, jkeenan wrote​:

On Tue Feb 26 05​:41​:34 2013\, nicholas wrote​:

perlvar says​:

Dan Collins did some bookkeeping on this RT today\, which pushed it to the top of the sorted-by-last-modification date in the New queue\,

Oh\, so I’m not the only one doing that. :-)

which in turn brought it to my attention.

My recommendation is that we close this ticket

I agree.

Closing as Rejected.

Thank you very much.

-- James E Keenan (jkeenan@​cpan.org)

p5pRT commented 7 years ago

@jkeenan - Status changed from 'open' to 'rejected'