Mailing List Archive

deprecating non-default postderef_qq
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
Re: deprecating non-default postderef_qq [ In reply to ]
On Sun, May 23, 2021 at 6:24 PM Ricardo Signes <perl.p5p@rjbs.manxome.org>
wrote:

> 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.
>

I agree with this. I have always thought that splitting this into two
features didn't make much sense (and in fact, use experimental always
enabled postderef_qq if you enabled postderef)

Leon
Re: deprecating non-default postderef_qq [ In reply to ]
On Sun, 23 May 2021 12:23:31 -0400
"Ricardo Signes" <perl.p5p@rjbs.manxome.org> wrote:

> That said, I believe this is a very niche feature that we are better
> served by eliminating. To do this, I propose:
...

That plan sounds reasonable to me.

And +1 to having a plan to sunset a feature bit. :)

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
Re: deprecating non-default postderef_qq [ In reply to ]
On Sun, May 23, 2021 at 6:24 PM Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:

> 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

Yes, this seems like a good plan.

Nicholas Clark
Re: deprecating non-default postderef_qq [ In reply to ]
"Ricardo Signes" <perl.p5p@rjbs.manxome.org> wrote:
>On Sun, May 23, 2021, at 12:23 PM, Ricardo Signes wrote:
>> 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 }".
>
>I would like to hereby a branch that makes this happen. I believe the work (at a very high level) is:

hereby <x> a branch?

> * add a deprecation warning when the "no feature 'postderef_qq'" behavior is triggered
> * make sure the perldiag entry indicates how to fix the error while keeping the old behavior
> * test updates

Could you clarify which if any of these will be affected?
"Eat more $pies-"
"Eat more $pies->"
"Eat more $pies->@"

Hugo
Re: deprecating non-default postderef_qq [ In reply to ]
On Sun, May 23, 2021, at 12:23 PM, Ricardo Signes wrote:
> 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 }".

I would like to hereby a branch that makes this happen. I believe the work (at a very high level) is:
* add a deprecation warning when the "no feature 'postderef_qq'" behavior is triggered
* make sure the perldiag entry indicates how to fix the error while keeping the old behavior
* test updates
--
rjbs
Re: deprecating non-default postderef_qq [ In reply to ]
On Tue, Jun 15, 2021, at 1:36 PM, hv@crypt.org <mailto:hv%40crypt.org> wrote:
> "Ricardo Signes" <perl.p5p@rjbs.manxome.org <mailto:perl.p5p%40rjbs.manxome.org>> wrote:
> >On Sun, May 23, 2021, at 12:23 PM, Ricardo Signes wrote:
> >> 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 }".
> >
> >I would like to hereby a branch that makes this happen. I believe the work (at a very high level) is:
>
> hereby <x> a branch?

Yes, right. "solicit"!

> > * add a deprecation warning when the "no feature 'postderef_qq'" behavior is triggered
> > * make sure the perldiag entry indicates how to fix the error while keeping the old behavior
> > * test updates
>
> Could you clarify which if any of these will be affected?
> "Eat more $pies-"
> "Eat more $pies->"
> "Eat more $pies->@"

I would not expect any of them to be affected. Here's perl without postderef_qq:
~$ perl -Mfeature=say -e '$pies = [1,2,3]; say "$pies-"'
ARRAY(0x7fd16980ac48)-
~$ perl -Mfeature=say -e '$pies = [1,2,3]; say "$pies->"'
ARRAY(0x7ffc1500ac48)->
~$ perl -Mfeature=say -e '$pies = [1,2,3]; say "$pies->@"'
ARRAY(0x7fbcce80ac48)->@
~$ perl -Mfeature=say -e '$pies = [1,2,3]; say "$pies->@*"'
ARRAY(0x7fecc100ac48)->@*

…and here's the sequence with postderef_qq:

~$ perl -E '$pies = [1,2,3]; say "$pies-"'
ARRAY(0x7fda0e00ac48)-
~$ perl -E '$pies = [1,2,3]; say "$pies->"'
ARRAY(0x7fee2700ac48)->
~$ perl -E '$pies = [1,2,3]; say "$pies->@"'
ARRAY(0x7f903600ac48)->@
~$ perl -E '$pies = [1,2,3]; say "$pies->@*"'
1 2 3

Only the case ->@* is going to change, so only it should warn.

--
rjbs
Re: deprecating non-default postderef_qq [ In reply to ]
"Ricardo Signes" <perl.p5p@rjbs.manxome.org> wrote:
>On Tue, Jun 15, 2021, at 1:36 PM, hv@crypt.org <mailto:hv%40crypt.org> wrote:
>> Could you clarify which if any of these will be affected?
>> "Eat more $pies-"
>> "Eat more $pies->"
>> "Eat more $pies->@"
>
>I would not expect any of them to be affected. Here's perl without
>postderef_qq:
>~$ perl -Mfeature=say -e '$pies = [1,2,3]; say "$pies-"'
>ARRAY(0x7fd16980ac48)-
>~$ perl -Mfeature=say -e '$pies = [1,2,3]; say "$pies->"'
>ARRAY(0x7ffc1500ac48)->
>~$ perl -Mfeature=say -e '$pies = [1,2,3]; say "$pies->@"'
>ARRAY(0x7fbcce80ac48)->@
>~$ perl -Mfeature=say -e '$pies = [1,2,3]; say "$pies->@*"'
>ARRAY(0x7fecc100ac48)->@*
>
>and here's the sequence with postderef_qq:
>
>~$ perl -E '$pies = [1,2,3]; say "$pies-"'
>ARRAY(0x7fda0e00ac48)-
>~$ perl -E '$pies = [1,2,3]; say "$pies->"'
>ARRAY(0x7fee2700ac48)->
>~$ perl -E '$pies = [1,2,3]; say "$pies->@"'
>ARRAY(0x7f903600ac48)->@
>~$ perl -E '$pies = [1,2,3]; say "$pies->@*"'
>1 2 3
>
>Only the case ->@* is going to change, so only it should warn.

Super, thanks for the clarification.

Hugo
Re: deprecating non-default postderef_qq [ In reply to ]
On Tue, Jun 15, 2021, at 1:56 PM, Ricardo Signes wrote:
> On Sun, May 23, 2021, at 12:23 PM, Ricardo Signes wrote:
>> 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 }".
>
> I would like to hereby solicit a branch that makes this happen. I believe the work (at a very high level) is:
> * add a deprecation warning when the "no feature 'postderef_qq'" behavior is triggered
> * make sure the perldiag entry indicates how to fix the error while keeping the old behavior
> * test updates

In reviewing outstanding "stuff we'd like to get moving so it can someday be finished," I found this thread.

Is there someone who would like to take this on? If not: *Hey Tony!* Is this something that could be gotten on your grant work plate?

--
rjbs