Stride in foreach ranges
Namespace
rswhite4 at googlemail.com
Fri Aug 30 07:11:05 PDT 2013
On Friday, 30 August 2013 at 06:31:39 UTC, Paul Jurczak wrote:
> Is there a better way to express a range with stride than this:
>
> foreach (i; iota(0, N, 2))
>
> Maybe something similar to F# syntax:
>
> foreach (i; 0..2..N)
>
> I found this thread suggesting syntax improvement
> http://forum.dlang.org/thread/bug-4112-3@http.d.puremagic.com/issues/
> but I don't think it produced any results.
>
> BTW, DMD produces faster code when for loop is used instead,
> with GDC it makes no difference.
That is strange because the FAQ says here:
http://dlang.org/faq.html#foreach
"[...]let the compiler do the optimization."
and
"Let the compiler pick!"
Can you prove this on DPaste?
More information about the Digitalmars-d-learn
mailing list