Skip Menu |
Report information
Id: 130330
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: alex.jakimenko [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: Whatever on the left side of array subscript range may cause hangs (@a[*-2..*]:exists)
Download (untitled) / with headers
text/plain 398b
To understand the issue, let's take a look at examples that *do* work. Code: my @a = <a b c d e>; say @a[2..*] Result: (c d e) Code: my @a = <a b c d e>; say @a[2..*]:exists Result: (True True True) Code: my @a = <a b c d e>; say @a[*-2..*] Result: (d e) Alright? Now with “:exists”: Code: my @a = <a b c d e>; say @a[*-2..*]:exists Result: (hangs forever, *-2..* is being reified)
Download (untitled) / with headers
text/plain 741b
On Mon, 12 Dec 2016 11:25:01 -0800, alex.jakimenko@gmail.com wrote: Show quoted text
> To understand the issue, let's take a look at examples that *do* work. > > Code: > my @a = <a b c d e>; say @a[2..*] > > Result: > (c d e) > > > Code: > my @a = <a b c d e>; say @a[2..*]:exists > > Result: > (True True True) > > > Code: > my @a = <a b c d e>; say @a[*-2..*] > > Result: > (d e) > > > > Alright? Now with “:exists”: > > Code: > my @a = <a b c d e>; say @a[*-2..*]:exists > > Result: > (hangs forever, *-2..* is being reified)
Here are some comments from jnthn: https://irclog.perlgeek.de/perl6/2016-12-12#i_13729493 FWIW, I'm not seeing a problem. You've contorted a piece of code into trying to reify an infinite number of elements...
Sooo… Are you saying that the behavior in provided examples is consistent?

On 2016-12-13 09:25:36, cpan@zoffix.com wrote:
Show quoted text
> On Mon, 12 Dec 2016 11:25:01 -0800, alex.jakimenko@gmail.com wrote:
> > To understand the issue, let's take a look at examples that *do*
> > work.
> >
> > Code:
> > my @a = <a b c d e>; say @a[2..*]
> >
> > Result:
> > (c d e)
> >
> >
> > Code:
> > my @a = <a b c d e>; say @a[2..*]:exists
> >
> > Result:
> > (True True True)
> >
> >
> > Code:
> > my @a = <a b c d e>; say @a[*-2..*]
> >
> > Result:
> > (d e)
> >
> >
> >
> > Alright? Now with “:exists”:
> >
> > Code:
> > my @a = <a b c d e>; say @a[*-2..*]:exists
> >
> > Result:
> > (hangs forever, *-2..* is being reified)
>
> Here are some comments from jnthn:
> https://irclog.perlgeek.de/perl6/2016-12-12#i_13729493
>
> FWIW, I'm not seeing a problem. You've contorted a piece of code into
> trying to reify an infinite number of elements...


RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 732b
On Tue, 13 Dec 2016 11:10:38 -0800, alex.jakimenko@gmail.com wrote: Show quoted text
> Sooo… Are you saying that the behavior in provided examples is consistent? >
As far as I can see, yes. The first two are lazy Ranges. The second two are non-lazy WhateverCodes. And as jnthn++ pointed out "The array subscripter decides whether to auto-viv for not based on .is-lazy". The reason it does so is so things like `my @a; @a[3..5] = 1 xx *; say @a` autovivicate, while still letting you do stuff like `@a[2..*]` to get a truncated result. In the example you point out as problematic, you're exploiting the autovivication feature to create an infinite loop, hence the hang. Is there still an issue on this ticket not covered by those explanations?
Yes. Why the behavior with and without :exists is different? Why does it have to be different?

On 2016-12-14 08:02:48, cpan@zoffix.com wrote:
Show quoted text
> On Tue, 13 Dec 2016 11:10:38 -0800, alex.jakimenko@gmail.com wrote:
> > Sooo… Are you saying that the behavior in provided examples is
> > consistent?
> >
>
> As far as I can see, yes. The first two are lazy Ranges. The second
> two are non-lazy WhateverCodes. And as jnthn++ pointed out "The array
> subscripter decides whether to auto-viv for not based on .is-lazy".
>
> The reason it does so is so things like `my @a; @a[3..5] = 1 xx *; say
> @a` autovivicate, while still letting you do stuff like `@a[2..*]` to
> get a truncated result.
>
> In the example you point out as problematic, you're exploiting the
> autovivication feature to create an infinite loop, hence the hang.
>
> Is there still an issue on this ticket not covered by those
> explanations?




This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org