davidl Wrote:
> Actually I'm not sure about what kind of bugs my d apps usually have.

I suggest every serious programmer to keep a document that contains all the 
bugs he/she/shi has  fixed in her/his/hir code, plus a note that explains such 
bug a bit.

This is a bug I have put 3 times in my D programs, that shows an-error prone 
design detail of D arrays:

import std.stdio: writefln;

void process(int[] arr) {
    arr.length = arr.length / 2;
    foreach (i, ref el; arr)
        el += 2;
}

void main() {
    auto a = new int[10];
    process(a);
    writefln(a);
}

I think D arrays have to be passed by reference by default or they have to be 
immutable. Such mixed thing just leads to troubles.

I have had another class troubles while translating C to do D. Global variables 
in C are initialized to 0, while in D floating point values (global too) are 
initialized to nan (or now signaling nan in D2), this leads to different 
results.

There are several other bugs I have had in D. The good thing is that, I am used 
to use lot of unit testing, so I can catch many of them. Around I see lot of D 
code with too few unittests (for example most of the code in Phobos has just 
few unittests. That's bad).

Bye,
bearophile

Reply via email to