[Issue 16566] hasLength should enforce that length has type size_t

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Oct 5 12:26:45 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=16566

Jonathan M Davis <issues.dlang at jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang at jmdavisProg.co
                   |                            |m

--- Comment #2 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
(In reply to Sophie from comment #1)
> What is the rationale for disallowing other numeric primitives for length,
> or types that act like numeric primitives?

It complicates code considerably for it to have to worry about length being
anything other than size_t, and the vast majority of existing code assumes that
length is size_t. Anything else just plain doesn't play well with a lot of
code, and making it play well would require being very careful about how length
was handled every time it was used. At one point, iota was changed so that it
supported ulong for length so that ranges over long or ulong could have a
length and contain the full range of values for long or ulong on a 32-bit
system. It caused more trouble than it was worth, and we changed it so that
iota's length was always size_t once again.


The newsgroup discussion that Andrei opened up in relation to this bug report:
http://forum.dlang.org/post/nsn75s$v8q$1@digitalmars.com

--


More information about the Digitalmars-d-bugs mailing list