Re: [perl #99658] sequence operator '...' timeout
Wouldn't 1,3,5,7 be a more reasonable result? The next value, 9 is greater than the end term, so it should stop? On 10/16/14, Carl Mäsak via RT perl6-bugs-follo...@perl.org wrote: bartolin (): Actually 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. 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.
[perl #99658] sequence operator '...' timeout
bartolin (): Actually 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. 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.
[perl #99658] sequence operator '...' timeout
Actually 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 If a limit is given, it must smartmatch exactly. If it does not, an infinite list results. For instance, since asymptotically approaching is not the same as equals, both of the following are infinite lists, as if you'd specified * for the limit rather than 0: 1,1/2,1/4 ... 0# like 1,1/2,1/4 ... * 1,-1/2,1/4 ... 0 # like 1,-1/2,1/4 ... * Likewise, this is all of the even numbers: my $end = 7; 0,2,4 ... $end To catch such a situation, it is advised to write an inequality instead: 0,2,4 ...^ { $_ $end } quote end One note to the original command my @odd = 1,3,5 ... 8; say @odd[^4] We can get around the assignment to @odd and thereby stay lazy: (1,3,5 ... 8)[^4]## works 1 3 5 7 (1,3,5 ... *)[^4]## same as above 1 3 5 7 So IMHO this is not a bug (and the ticket could be closed).
[perl #99658] sequence operator '...' timeout
On Tue Sep 20 23:03:06 2011, woosley.xu wrote: (13:50:48) woosley: rakudo: my @a = 1,3,5 ... *; say @a[^4] (13:50:49) p6eval: rakudo f1c805: OUTPUT«1 3 5 7» (13:46:40) woosley: perl6: my @odd = 1,3,5 ... 8; say @odd[^4] (13:47:05) p6eval: rakudo f1c805, niecza v9-32-g380d891: OUTPUT«(timeout)» according to S03, '1,3,5 ... 8' should act as '1,3,5 ... *' S03 now says the opposite: -- Likewise, this is all of the even numbers: my $end = 7; 0,2,4 ... $end -- Rejecting ticket. -- Will Coke Coleda
[perl #99658] sequence operator '...' timeout
On Sun May 27 21:13:06 2012, coke wrote: On Tue Sep 20 23:03:06 2011, woosley.xu wrote: (13:50:48) woosley: rakudo: my @a = 1,3,5 ... *; say @a[^4] (13:50:49) p6eval: rakudo f1c805: OUTPUT«1 3 5 7» (13:46:40) woosley: perl6: my @odd = 1,3,5 ... 8; say @odd[^4] (13:47:05) p6eval: rakudo f1c805, niecza v9-32-g380d891: OUTPUT«(timeout)» according to S03, '1,3,5 ... 8' should act as '1,3,5 ... *' S03 now says the opposite: -- Likewise, this is all of the even numbers: my $end = 7; 0,2,4 ... $end -- Rejecting ticket. 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.) -- Will Coke Coleda
[perl #99658] sequence operator '...' timeout
# New Ticket Created by woosley. xu. # Please include the string: [perl #99658] # in the subject line of all future correspondence about this issue. # URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=99658 (13:50:48) woosley: rakudo: my @a = 1,3,5 ... *; say @a[^4] (13:50:49) p6eval: rakudo f1c805: OUTPUT«1 3 5 7» (13:46:40) woosley: perl6: my @odd = 1,3,5 ... 8; say @odd[^4] (13:47:05) p6eval: rakudo f1c805, niecza v9-32-g380d891: OUTPUT«(timeout)» according to S03, '1,3,5 ... 8' should act as '1,3,5 ... *' -- woosley.xu.