Closed p5pRT closed 7 years ago
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
On Tue\, 26 Feb 2013 05:41:35 -0800\, Nicholas Clark (via RT) \perlbug\-followup@​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​: 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/
The RT System itself - Status changed from 'new' to 'open'
On Tue\, Feb 26\, 2013 at 9:33 AM\, H.Merijn Brand \h\.m\.brand@​xs4all\.nl wrote:
I think that we should deprecate the use of *all* of these.
+1!
+1
-- David Golden \xdg@​xdg\.me Take back your inbox! → http://www.bunchmail.com/ Twitter/IRC: @xdg
* Nicholas Clark \perlbug\-followup@​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
On Tue\, Feb 26\, 2013 at 10:10:09AM -0500\, Ricardo Signes wrote:
* Nicholas Clark \perlbug\-followup@​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
On Tue\, 26 Feb 2013 15:53:16 +0000\, Nicholas Clark \nick@​ccl4\.org wrote:
On Tue\, Feb 26\, 2013 at 10:10:09AM -0500\, Ricardo Signes wrote:
* Nicholas Clark \perlbug\-followup@​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/
On Tue\, Feb 26\, 2013 at 10:11 AM\, H.Merijn Brand \h\.m\.brand@​xs4all\.nl wrote:
On Tue\, 26 Feb 2013 15:53:16 +0000\, Nicholas Clark \nick@​ccl4\.org wrote:
On Tue\, Feb 26\, 2013 at 10:10:09AM -0500\, Ricardo Signes wrote:
* Nicholas Clark \perlbug\-followup@​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/
* Reini Urban \rurban@​x\-ray\.at [2013-02-26T11:45:23]
On Tue\, 26 Feb 2013 15:53:16 +0000\, Nicholas Clark \nick@​ccl4\.org wrote:
Should we deprecate them in time for v5.18.0?
Sure
I'm with Reini.
-- rjbs
Merged to blead\, so marking as resolved.
Nicholas Clark
@nwc10 - Status changed from 'open' to 'resolved'
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 \
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
@nwc10 - Status changed from 'resolved' to 'open'
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
$ 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
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?
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
Thanks\, unblocking.
-- rjbs
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
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)
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
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)
@jkeenan - Status changed from 'open' to 'rejected'
Migrated from rt.perl.org#116943 (status was 'rejected')
Searchable as RT116943$