On Friday, 12 February 2016 at 16:52:17 UTC, ixid wrote:
On Friday, 12 February 2016 at 15:59:09 UTC, Jonathan M Davis
wrote:
It would be far better IMHO to just do a check in iota and
throw a RangeError if the length wouldn't fit in size_t.
Having length ever be anything other than size_t is just going
to cause problems with other ranges. On 32-bit systems, you
lose out on the ability to have a range that covers all values
of long or ulong, but that's of very limited usefulness
anyway, and as long as the number of elements is no greater
than size_t.max, it would be fine - which would cover
virtually all use cases. No, it's not perfect, but allowing
length to be anything but size_t just causes bugs - especially
in generic code.
- Jonathan M Davis
What about a template overload where you can set the length
type as separate from the type of the range elements?
No other range has anything but size_t for its length. It's what
arrays use. It's what the container types use. Code in general is
going to assume that length is size_t. I think that having any
range types with a length type of anything but size_t is a
mistake. It interacts badly with everything else. The post that
started this thread is just one example of that.
- Jonathan M Davis