On Mon, 18 May 2009 04:28:24 +0400, Andrei Alexandrescu 
<seewebsiteforem...@erdani.org> wrote:

Consider:

     foreach (x; 1.0 .. 4.1) writeln(x);
     foreach_reverse (x; 1.0 .. 4.1) writeln(x);

This sucks. foreach with interval for floating-point types should be disallowed.


Andrei

It's useless, unless a step is specified (btw, integer iteration would benefit 
from having a step, too)

I don't mind if the whole .. feature is removed. It could be implemented in a 
library, with an optional step:

foreach (x; range(0, 100)) { // step is 1 implicitly
   // ...
}

foreach (x; range(0, 100, 2)) { // explicit step
   // ...
}

This feels more functional, although slightly longer to type.

Reply via email to