Iota

Paul Backus snarwin at gmail.com
Sat Aug 6 17:40:54 UTC 2022


On Saturday, 6 August 2022 at 15:52:13 UTC, H. S. Teoh wrote:
> Here's a first stab at it. Let T be the incoming type (I'm 
> leaning against separately parametrizing the 
> start/end/increment types, I think that's just needlessly 
> complex). Then:
>
> [...]

I think there's a case to be made for allowing a separate 
increment type, so that you can have e.g. pointers as endpoints 
with a ptrdiff_t increment. But it's not super essential.

There's also the single-argument iota(n) case to consider. If 
we're going to go all-in on structural typing, we need a 
convention for obtaining the "zero" value of a generic type T. 
The obvious choice is T.init, but that won't work for 
floating-point types, so maybe `cast(T) 0` is better?


More information about the Digitalmars-d mailing list