Bug 14832 – iota(UL) + array doesn't work

Status
NEW
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2015-07-26T15:15:04Z
Last change time
2024-12-01T16:24:54Z
Keywords
pull
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: phobos#10138 →

Comments

Comment #0 by bearophile_hugs — 2015-07-26T15:15:04Z
void main() { import std.array: array; import std.range: iota; iota(10UL).array; } dmd v2.068.0-b1 gives (32 bit system): ..\src\phobos\std\array.d(518): Error: static assert "Argument types in (ulong) are not all convertible to size_t: (ulong)" ..\src\phobos\std\array.d(111): instantiated from here: uninitializedArray!(ulong[], ulong) test.d(4): instantiated from here: array!(Result)
Comment #1 by schveiguy — 2015-08-10T19:53:39Z
Comment #2 by bugzilla — 2015-08-15T01:10:16Z
To me this looks invalid. I see no reason to support creating arrays from ulongs.
Comment #3 by dmitry.olsh — 2015-08-15T06:59:06Z
Also the funny thing is that https://github.com/D-Programming-Language/phobos/pull/3544 adds support for ulong length which AFAIK only iota on ulong give and BECAUSE the element type is ulong.sizeof == 8 bytes long nobody will ever be able to call array on > ~512 million long iota. So all of that effort is leading nowhere, just drop the ulong length please.
Comment #4 by schveiguy — 2015-08-16T09:50:25Z
(In reply to Walter Bright from comment #2) > To me this looks invalid. I see no reason to support creating arrays from > ulongs. You mean from ranges with ulong length? I don't see why. ulong[] is a valid type, and a reasonable request. How do I make a ulong[] from iota on 32-bit? (In reply to Dmitry Olshansky from comment #3) > Also the funny thing is that > https://github.com/D-Programming-Language/phobos/pull/3544 > > adds support for ulong length which AFAIK only iota on ulong give and > BECAUSE the element type is ulong.sizeof == 8 bytes long nobody will ever be > able to call array on > ~512 million long iota. The point is not to make arrays of larger than size_t elements, the point is to make arrays out of small ranges that happen to use ulong as a length. > So all of that effort is leading nowhere, just drop the ulong length please. You mean from iota? or support from array? Why should a range that has a ulong length of 10 be disallowed? Note that a file may have ulong length even on a 32-bit system. This would mean creating an array out of a file stream range (that reasonably supplies a ulong length) would be disallowed, even when the length is small. I really don't understand the objections here, this code is very reasonable. It means code that makes sense on both 32-bit and 64-bit systems fails on 32-bit systems.
Comment #5 by schveiguy — 2015-08-19T01:58:45Z
PR seems to be rejected by 3 other major players, so maybe someone else will have better luck with a different solution.
Comment #6 by hsteoh — 2015-08-22T15:04:13Z
Comment #7 by robert.schadek — 2024-12-01T16:24:54Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10138 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB