A little about myself: I'm on Mac OSX Lion (64 bit, obviously), and I'm a long time Java developer interested in learning about D.
I took a copy of the D programming language, and I'm a little confused with a few things. Firstly, if I try something like the following (directly from the book):
int[] months = new int[12]; foreach (i, ref month; months) { month = i + 1; }
I get the following error:
Error: cannot implicitly convert an expression (i + 1LU) of type ulong to int
This is fixed by changing i
to int i
.
I think this is due to the fact that the automatic type for numbers on a 64-bit platform is ulong
, so type inference does not really work.
Now I have the following problem:
bool binarySearch(T)(T[] input, T value) {
This returns the following compilation error:
Error: cannot implicitly convert an expression (input.length / 2LU) of type ulong to int
Casting fixes this, but I would prefer. I also get other stupid errors related to getting long
values โโfrom calculations and then unable to use them to index into arrays. D 64-bit support still not sniffed? What can I do to avoid future troubles while learning D? The explicit use of translations and types everywhere seems to be the opposite of what attracted me to the language in the first place ...
user1273263
source share