foreach (x; a .. b) and foreach_reverse (x; a .. b) should be

bearophile bearophileHUGS at lycos.com
Mon May 18 09:25:43 PDT 2009


Steven Schveighoffer:

> hm... I guess that's one way to look at it.  I don't anticipate many  
> typing this by mistake.  One thing that would be left to decide, 1..4  
> means 1-2-3, should 4..1 mean 4-3-2 or 3-2-1?  I'd vote for 4-3-2 to be  
> consistent on having x..y mean inclusive to exclusive.

Python shows the coherent behavior:

>>> list(xrange(4, 1))
[]
>>> list(xrange(4, 1, -1))
[4, 3, 2]

It's easy to convince me that other behaviors are more correct.

Bye,
bearophile



More information about the Digitalmars-d mailing list