On 2009-Sep-20, at 12:48 am, Larry Wall wrote:
Yes, I think it's fair to say that either list context OR a :by turns
a Range into a RangeIterator that matches like a list.  Hence, this
ought to match:

   (1,3,5) ~~ (1..5 :2by)

OK; but I still have to ask why it returns a RangeIterator instead of a SeriesIterator or any other plain Iterator. Is there some reason to make :by work on Ranges that way instead of being, say, an adverb on "..."? I can see that it's obvious and useful to get a list by filling in the values between two endpoints, but that also applies to a pair, or a list of two items.

Having :by effectively work like a list at least reduces the confusion in the case of numbers, but we're still left with a puzzle when it comes to strings: Is "b" ~~ "a".."az" false because it's not the case that a < b < az, or is it true because expanding the list produces a, b, c, ... ax, ay, az? The former according to spec; but the latter according to someone who expects a parallel with ints. (Apparently Rakudo expects that too, at least for the moment.) Of course, in this case :by doesn't help because there is only one way to increment strings.

If we give up the Range/RangeIterator duality, we still have the two different concepts, but I think people will be less tempted to try making them line up together mentally. (Different things should look different.) I don't see that we would lose any functionality (make the :by features work with "..."; or keep ".." and "..." as two ways to make series, and use infix:<to> for Ranges; or anything else that distinguishes ranges from iterators). What's the big advantage in keeping it the way it is?


-David

Reply via email to