Iota
Paul Backus
snarwin at gmail.com
Thu Aug 4 17:52:46 UTC 2022
On Thursday, 4 August 2022 at 16:28:14 UTC, React wrote:
> What I want to highlight, it's the fact that iota seems flawed:
> it assumes that every type supporting increment operators will
> generate a nice, consecutive, ordered sequence of values.
>
> Iota specialises on floating point values exactly because of
> the problem above, but assumes that *any* other type will
> nicely behave as long you can put a ++ near a value.
>
> We can ignore the hypotetical situation in which someone will
> find an unusual usage of ++ (probably there is one person that
> never imagined that << can be used for console output), but we
> already have a candidate where iota will fail: CustomFloat from
> std.numeric.
Yeah, this is a classic case of what Andrei calls ["generality
creep"][1].
You start out with the obviously-correct core functionality. Then
you start gradually extending it to handle new edge cases. Each
one seems reasonable enough on its own, but by the end of the
process, you find yourself with an API that's complex and hard to
use, wondering where it all went wrong.
[1]: https://forum.dlang.org/thread/q6plhj$1l9$1@digitalmars.com
More information about the Digitalmars-d
mailing list