Dave Whipp wrote: > To squint at this slightly, in the context that we already have 0...1e10 as > a sequence generator, perhaps the semantics of iterating a range should be > unordered -- that is, > > for 0..10 -> $x { ... } > > is treated as > > for (0...10).pick(*) -> $x { ... } > > Then the whole question of reversibility is moot.
No thanks; I'd prefer it if $a..$b have analogous meanings in item and list contexts. As things stand, 10..1 means, in item context, "numbers that are greater or equal to ten and less than or equal to one", which is equivalent to "nothing"; in list context, it means "an empty list". This makes sense to me; having it provide a list containing the numbers 1 through 10 creates a conflict between the two contexts regardless of how they're arranged. As I see it, C< $a..$b > in list context is a useful shorthand for C< $a, *.succ ... $b >. You only get into trouble when you start trying to have infix:<..> do more than that in list context. If anything needs to be done with respect to infix:<..>, it lies in changing the community perception of the operator. The only reason why we're having this debate at all is that in Perl 5, the .. operator was used to generate lists; so programmers coming from Perl 5 start with the expectation that that's what it's for in Perl 6, too. That expectation needs to be corrected as quickly as can be managed, not catered to. But that's not a matter of language design; it's a matter to be addressed by whoever's going to be writing the Perl 6 tutorials. -- Jonathan "Dataweaver" Lang