Denis Derman <> changed:

           What    |Removed                     |Added
                 CC|                            |

--- Comment #1 from Denis Derman <> 2011-02-09 05:41:42 PST 
I'm unsure whether this is a good thing. The issue is, for me, this feature
would only apply to numeric intervals (probably even only on integral ones).
While the notion of "by-step iteration" is completely general; I guess simply
orthogonal to sequence / iteration / range.
Thus, I would prefere a range factory like

    auto byStep (R) (int step) if (...)

typical use case:

    foreach (n ; iota(1..1000).byStep(3)) {...}

or better (see
    foreach (n ; (1..1000).byStep(3) {...}

What do you think?

Negative step meaning backwards? So that we get reverse for free... An issue
is, if this is not the case but negative step is intepreted literally, we get a
very weird semantics compared to apparent meaning.

Example for the simplest case of reverse iteration. Should iterating backwards
on 0..4 (meaning 3->2->1->0) be written (more direct):
    foreach (n ; (0..4).byStep(-1))
(translation in the case of indices:)
    foreach (i ; (0..a.length).byStep(-1))

or instead (more logical but imo completely unintuitive and difficult):
    foreach (n ; (3..-1).byStep(-1))
(translation in the case of indices:)
    foreach (i ; (a.length-1..-1).byStep(-1))

By the way, this issue applies to your proposal as well: what does 1..3:-2
Actually mean?
Finally, if ever we had a step syntax for i..j, I would prefere '/' than ':',
read as "by": 
    foreach (; i..j:k
--> traverse the interval i..j 'by' (steps of) k.


Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to