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
sequence operator '...' timeout #2477
Comments
From redicaps@gmail.com(13:50:48) woosley: rakudo: my @a = 1,3,5 ... *; say @a[^4] (13:46:40) woosley: perl6: my @odd = 1,3,5 ... 8; say @odd[^4] according to S03, '1,3,5 ... 8' should act as '1,3,5 ... *' -- |
From @cokeOn Tue Sep 20 23:03:06 2011, woosley.xu wrote:
S03 now says the opposite: -- my $end = 7; Rejecting ticket. -- |
The RT System itself - Status changed from 'new' to 'open' |
@coke - Status changed from 'open' to 'rejected' |
From @cokeOn Sun May 27 21:13:06 2012, coke wrote:
Whops. This isn't the opposite of what you said, ti's the same thing. Reopening ticket. (note to self, don't wrangle tickets at this hour.) -- |
@coke - Status changed from 'rejected' to 'open' |
From @usev6Actually I don't think S03 says that '1,3,5 ... 8' should act as '1,3,5 ... *' As I understand it '1,3,5 ... 8' gives an infinite list with all even numbers. '1,3,5 ... *' also gives an infinite list with all even numbers -- but this one is lazy. So there is a difference in behaviour: When assigning to an array with 'my @odd = 1,3,5 ... 8;' all elements of the sequence have to be computed and smart matched agains '8'. This match never results in True and therefore we get a timeout, finally. In the other case ('my @odd = 1,3,5 ... *') "the sequence has no limit" (quote from S03) and the assignment can be lazy e.g. the values don't have to be computed and smart matched against something. S03 explicitly notes: ==== quote 1,1/2,1/4 ... 0 # like 1,1/2,1/4 ... * Likewise, this is all of the even numbers: my $end = 7; To catch such a situation, it is advised to write an inequality instead: 0,2,4 ...^ { $_ > $end } One note to the original command
We can get around the assignment to @odd and thereby stay lazy:
So IMHO this is not a bug (and the ticket could be closed). |
From @masakbartolin (>):
I think this reasoning is sound, and whereas it would be awesome if we could always read the mind of the user and not get stuck in infinite loops trying to compute infinite sequences -- the place we are is kind of a local minimum and has an internal consistency. That is, we could perhaps do better in the future, and not hang on this one. But it's not clear to me how to do that without making the current model more complex for relatively little gain. Rejecting ticket. |
@masak - Status changed from 'open' to 'rejected' |
From 1parrota@gmail.comWouldn't "1,3,5,7" be a more reasonable result? The next value, "9" is On 10/16/14, Carl Mäsak via RT <perl6-bugs-followup@perl.org> wrote:
|
From @pmichaudOn Fri Oct 17 09:34:45 2014, 1parrota@gmail.com wrote:
Not all sequences are increasing, or even monotonic, or even numeric. We've not found any guide for inexact termination points that is reliable enough to use, or better than the recommended (and explicit): 1, 3, 5, ... * >= 8 Pm |
Migrated from rt.perl.org#99658 (status was 'rejected')
Searchable as RT99658$
The text was updated successfully, but these errors were encountered: