Front page | perl.perl5.porters |
Postings from May 2021
deprecating non-default postderef_qq
Thread Next
From:
Ricardo Signes
Date:
May 23, 2021 16:24
Subject:
deprecating non-default postderef_qq
Message ID:
00e4097e-b1c9-4d24-90d7-127b8edd19d6@beta.fastmail.com
Porters,
I continue to work through my list of cruft, experiments, and old defaults. Today: *postderef_qq*.
~$ perl -le '$r=[1,2,3]; print "@$r"'
1 2 3
~$ perl -le '$r=[1,2,3]; print "$r->@*"'
ARRAY(0x7fc04080a648)->@*
~$ perl -lE '$r=[1,2,3]; print "$r->@*"'
1 2 3
In that last one, -E turns on the postderef_qq feature, which allows postfix dereferencing inside of interpolative strings. This was made separate from postderef because it was less clearly invalid syntax. After all, that second one-liner did run. And if its $r had been an object with stringification, or just a string, it might have even made sense.
That said, I believe this is a very niche feature that we are better served by eliminating. To do this, I propose:
* In 5.36.0: We make cases where postderef_qq would occur, if not for the feature being off, issue a deprecation warning, but act as before. That is: "Eat more $pies->@{ $x }" will interpolate $pies and @$x but also warn. User can eliminate the warning by changing their code to read "Eat more $pies\->@{ $x }".
* In 5.40.0: We make postderef_qq effectively on by default, without the option to disable it, as postderef itself is.
This is not a massive improvement in the language, and I'm not here to sell it as one. It's a small reduction in complexity by making the syntax just a bit more consistent. This is a bit like our work to call out the use of not-really-there metacharacters like \j or left braces that parameterize nothing in regex. I am specifically not attempting to provide a generalized "interpolate an expression" syntax here.
--
rjbs
Thread Next
-
deprecating non-default postderef_qq
by Ricardo Signes