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

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

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



From: "Sam S." <smls75 [...] gmail.com>
To: rakudobug [...] perl.org
Date: Fri, 20 Jan 2017 16:28:53 +0100
Subject: Weirdness when mixing `..` and `...` without parens
Download (untitled) / with headers
text/plain 500b
When the operators `..` and `...` are used in the same comma-separated list, without disambiguating parentheses, the results are weird: ➜ say 1..2,7,5...2; (1..2) ➜ say 1..1,7,5...2; (1..1 7 5 4 3 2) ➜ say 1,7,5...2; Unable to deduce arithmetic or geometric sequence from 1,7,5 (or did you really mean '..'?) in block <unit> at -e line 1 Of those examples, the only one that outputs what I expected, is the third one. What is even going on in the other two?
It numifies ranges so that the number of elements is used. In other words, 1..2 works like 2 and 1..1 works like 1.

It looks like it hurts when you do this…

On 2017-01-20 07:29:03, smls75@gmail.com wrote:
Show quoted text
> When the operators `..` and `...` are used in the same comma-separated
> list, without disambiguating parentheses, the results are weird:
>
> ➜ say 1..2,7,5...2;
> (1..2)
>
> ➜ say 1..1,7,5...2;
> (1..1 7 5 4 3 2)
>
> ➜ say 1,7,5...2;
> Unable to deduce arithmetic or geometric sequence from 1,7,5 (or
> did you really mean '..'?)
> in block <unit> at -e line 1
>
> Of those examples, the only one that outputs what I expected, is the
> third one.
> What is even going on in the other two?


Download (untitled) / with headers
text/plain 488b
Show quoted text
> It numifies ranges so that the number of elements is used. In other > words, 1..2 > works like 2 and 1..1 works like 1.
No, if it worked like that then the first two examples would throw the same error as the third, instead of exhibiting behaviors that are both different from that and from each other. Here are two more examples, showing the difference in case of an actual arithmetic series: ➜ say 1..1, 3 ... 7; (1..1 3 4 5 6 7) ➜ say 1, 3 ... 7; (1 3 5 7)


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