digitalmars.D.learn - std.array: array, ulong and Win32
- ixid (8/8) Aug 09 2015 This seems like a reasonable use but errors, obviously I can do
- anonymous (9/17) Aug 09 2015 That's because the offsets of the elements are different. Reading
- ixid (4/6) Aug 09 2015 It seems like bearophile beat me to it. Good to see he's still
- Steven Schveighoffer (3/8) Aug 10 2015 PR: https://github.com/D-Programming-Language/phobos/pull/3544
- Timon Gehr (5/13) Aug 09 2015 Array literals do cast implicitly.
This seems like a reasonable use but errors, obviously I can do it in many other ways: ulong[] result = iota(1UL, 10UL).array; Error: static assert "Argument types in (ulong) are not all convertible to size_t: (ulong)" C:\D\dmd2\src\phobos\std\array.d 516 And while I'm here why do arrays not implicitly cast? ulong is happy to accept uint values but ulong[] will not accept uint[].
Aug 09 2015
On Sunday, 9 August 2015 at 20:13:38 UTC, ixid wrote:This seems like a reasonable use but errors, obviously I can do it in many other ways: ulong[] result = iota(1UL, 10UL).array; Error: static assert "Argument types in (ulong) are not all convertible to size_t: (ulong)" C:\D\dmd2\src\phobos\std\array.d 516Yup, bug. Please file an issue at <http://issues.dlang.org/>.And while I'm here why do arrays not implicitly cast? ulong is happy to accept uint values but ulong[] will not accept uint[].That's because the offsets of the elements are different. Reading a ulong means reading 8 bytes. But in a uint[] every element only takes up 4 bytes. So every 2 uint elements would be combined into one ulong. And if the uint[] doesn't have an even number of elements, you'd read beyond array bounds. You can do that conversion explicitly, but for an implicit conversion that would be too surprising.
Aug 09 2015
On Sunday, 9 August 2015 at 20:33:10 UTC, anonymous wrote:On Sunday, 9 August 2015 at 20:13:38 UTC, ixid wrote:Yup, bug. Please file an issue at <http://issues.dlang.org/>.It seems like bearophile beat me to it. Good to see he's still alive. https://issues.dlang.org/show_bug.cgi?id=14832
Aug 09 2015
On 8/9/15 4:40 PM, ixid wrote:On Sunday, 9 August 2015 at 20:33:10 UTC, anonymous wrote:PR: https://github.com/D-Programming-Language/phobos/pull/3544 -SteveOn Sunday, 9 August 2015 at 20:13:38 UTC, ixid wrote:Yup, bug. Please file an issue at <http://issues.dlang.org/>.It seems like bearophile beat me to it. Good to see he's still alive. https://issues.dlang.org/show_bug.cgi?id=14832
Aug 10 2015
On 08/09/2015 10:13 PM, ixid wrote:This seems like a reasonable use but errors, obviously I can do it in many other ways: ulong[] result = iota(1UL, 10UL).array; Error: static assert "Argument types in (ulong) are not all convertible to size_t: (ulong)" C:\D\dmd2\src\phobos\std\array.d 516 ...I consider this to be a bug. Also, it's annoying static assert abuse.And while I'm here why do arrays not implicitly cast?Array literals do cast implicitly.ulong is happy to accept uint values but ulong[] will not accept uint[].Many reasons. E.g. it would be a hidden not-necessarily-constant-time operation.
Aug 09 2015