Iota

Walter Bright newshound2 at digitalmars.com
Sat Aug 6 16:35:08 UTC 2022


I haven't used iota much at all. But consider this. We all know exactly what 
integer arithmetic does, as long as it doesn't overflow.

     for (i = start; i < end; i += step)

I've been around the block enough times with floating point arithmetic that I 
would *not* use iota with it. The reason is simple enough - if each step is an 
addition, there's an extra rounding error added on with each increment.

     for (d = start; d < end; d += step)

as opposed to:

     for (d = start; d < end; (d = start + step * i, ++i))

which doesn't have roundoff error accumulation, and might even be faster. How 
would I know which one iota uses?

I suggest seriously considering (for std2) having iota only work with integers. 
Floating point stuff can be done as a wrapper around iota.

But the core iota will be simple and understandable.



More information about the Digitalmars-d mailing list