Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite recursion when doing 0 .. *-1 (or 0 ..^ *-1) in Rakudo #2261

Closed
p6rt opened this issue Nov 16, 2010 · 4 comments
Closed

Infinite recursion when doing 0 .. *-1 (or 0 ..^ *-1) in Rakudo #2261

p6rt opened this issue Nov 16, 2010 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Nov 16, 2010

Migrated from rt.perl.org#79270 (status was 'resolved')

Searchable as RT79270$

@p6rt
Copy link
Author

p6rt commented Nov 16, 2010

From @masak

<masak> rakudo​: my @​a = <a b c>; @​a[0 ..^ *-1] >>~=>> "\n"; say @​a.perl
<p6eval> rakudo 015d77​: OUTPUT«(timeout)»
* masak submits rakudobug
<colomon> rakudobug for that?
<masak> colomon​: locally, I get a stack overflow.
<colomon> but do you think it is correct?
<colomon> you're mixing positional whatever with range whatever
<masak> oh, I can't do that?
<colomon> probably shouldn't stack overflow, but...
<masak> I totally thought I could.
<masak> it feels so natural.
<masak> rakudo​: my @​a = <a b c>; @​a[0 ..^ *-1]
<p6eval> rakudo 015d77​: OUTPUT«(timeout)»
<colomon> well, do you know if it is (0 ..^ *) - 1 or 0 ..^ (*-1) (for
starters)?
<masak> I'm assuming the latter, for precedence reasons.
<colomon> and if it is the later, you're making a Range with an Int on
one side and a closure on the other
<masak> so?
<masak> that's what WhateverCode is; a closure.
<masak> I don't see the fundamental difference to ordinary ranging
with Whatever.
<colomon> ranges don't participate in WhateverCode, do they?
<masak> I don't know.
<colomon> Certainly 1..* does not generate a closure
<masak> S09​:245 has @​array[0 .. *-1] as an example of valid slicings.
<colomon> (It does look like it should parse as 0..(*-1))
<jnthn> masak​: In [0..*-1] the *-1 would...yes, that. :)
<masak> jnthn​: that's what I expected.
<masak> or rather, I don't care much how it works implementation-wise
(as long as it works), but that was the precedence I assumed.
<colomon> "For any prefix, postfix, or infix operator that would be
curried by a Whatever, a WhateverCode also autocurries it"
<colomon> to me, that pretty explicitly leaves out the 0..*-1 case
<masak> colomon​: even though S09 says it should work?
<colomon> masak​: the spec is known to have errors
<masak> colomon​: but it would *suck* if this didn't work!
<masak> colomon​: and TimToady wrote that part of S09, so it's not like
it's untrustworthy because of many chefs.
<colomon> personally, I'm not seeing any reason to have the above
quote... it seems like anything hit with a WhateverCode could curry.
<colomon> masak​: TimToady++ is a genius, but he does make mistakes.
<masak> colomon​: well, what I'm saying doesn't depend on TimToady not
making mistakes. it depends on what feels right from a user
perspective.
<masak> and if I won't be able to write [0 .. *-1], I'll fork and make
my own Perl 6.
<jnthn> .oO( Who'd be less tormenting to the implementer... )
<colomon> Look, I don't see any obvious harm in allowing that. But
presumably the specquote is there for a reason which I do not
understand.

@p6rt
Copy link
Author

p6rt commented Jul 23, 2011

From @masak

<masak> perl6​: my @​e = 1, 2, 3; .say for @​e[0 ..^ *]
<p6eval> rakudo 922500, niecza v7-44-g54b5188​: OUTPUT«(timeout)»
<p6eval> ..pugs​: OUTPUT«pugs​: out of memory (requested 1048576 bytes)␤»
<masak> for something I think should work, the implementations seem
unusually united against me.
* masak goes to read S09
<moritz> nom​: my @​e = 1, 2, 3; .say for @​e[0 ..^ *]
<p6eval> nom​: OUTPUT«1␤2␤3␤»
* masak hugs nom
<masak> ok, S09 supports my belief that @​e[0 ..^ *] shouldn't loop infinitely.
* masak submits rakudobug

Specifically, S09​:675 talks about cases like this.

Oh, and as evidenced by moritz++' evaluation, this already works in nom.

@p6rt
Copy link
Author

p6rt commented Sep 30, 2011

From @moritz

works now, and tested in t/spec/S02-types/array.t

@p6rt
Copy link
Author

p6rt commented Sep 30, 2011

@moritz - Status changed from 'new' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant