std.range.iota enhancement: supporting more types (AKA issue 10762)

Jakob Ovrum jakobovrum at gmail.com
Sat Dec 28 12:07:28 PST 2013


On Saturday, 28 December 2013 at 19:22:25 UTC, Francesco 
Cattoglio wrote:
> On Saturday, 28 December 2013 at 16:13:45 UTC, Jakob Ovrum 
> wrote:
>> Alright, so require division for bidirectionality when given a 
>> custom step. There's no reason division should be required for 
>> bidirectionality in the most common case of iota(start, end).
>
> Ok, now I finally get your point. It goes something along the 
> lines of: "if no step is provided, then we can assume end can 
> be reached by just stepping forward (incrementing by one)". It 
> makes sense, but personally I don't like to make assumptions. I 
> think assumptions in library code are one of the worst sources 
> of nasty bugs in user code.

As long as `start < end` is true in the beginning, that's a 
perfectly reasonable assumption to make, especially if "end can 
be reached" means `start >= end` is true after some `n` number of 
increments.

If we can't make any assumptions about the chosen concept 
primitives then they're no good as primitives at all.


More information about the Digitalmars-d mailing list