Iota

Paul Backus snarwin at gmail.com
Fri Aug 5 15:20:12 UTC 2022


On Friday, 5 August 2022 at 00:12:40 UTC, Steven Schveighoffer 
wrote:
> As for the floating point thing, `foreach(i; 0.5 .. 7.6)` 
> works, it should too for `iota`.

Argument by analogy like this is exactly what leads to generality 
creep in the first place. You can just as easily say, "`for (auto 
i = start; i < end; i++)` works for any type that overloads `<` 
and `++`, so `iota(start, end)` should do the same", and then you 
end up with the exact problem OP describes.

There has to be some deeper principle that lets you decide which 
analogies are valid and which aren't. Like, what is our purpose 
for including `iota` in Phobos, when we already have more general 
facilities like `recurrence`, `sequence`, and `generate`; and 
does adding a particular feature to `iota` serve that purpose?

In this case I think your conclusion is correct, but the 
reasoning behind it is iffy.


More information about the Digitalmars-d mailing list