"IndexType" for ranges

Jonathan M Davis jmdavisProg at gmx.com
Tue Oct 2 11:02:04 PDT 2012


On Tuesday, October 02, 2012 19:37:18 monarch_dodra wrote:
> On Tuesday, 2 October 2012 at 17:07:19 UTC, monarch_dodra wrote:
> > [SNIP]
> 
> You know what, I think I have a better. Idea. All of this came up
> because I've had iota break my compiles WAY more often then I'd
> have liked. But I think I know of another solution.
> 
> I think it would be nice if we enforced that all ranges used
> size_t. Everywhere. And it was enforced.
> 
> I'm sorry, I like extremes.

Personally, I'd love that. The problem is that iota was specifically changed to 
use ulong to support handling long and ulong properly on 32-bit systems. 
Without it, you can't actually use long or ulong with a step of 1 beyond 
uint.max (at least, I _think_ that that was the issue). Requiring that the 
length and indices be size_t undermines that.

Now, I have no idea how much of a problem that realistically is. After all, 
you can't have an array of length > uint.max or 32-bit systems, so restricting 
iota to a length of uint.max isn't necessarily all than unreasonable IMHO. And 
per that argument, we _could_ change iota to use size_t again and just 
outright require that length and indices be size_t. 

- Jonathan M Davis


More information about the Digitalmars-d mailing list