The current status of D?

bearophile bearophileHUGS at lycos.com
Tue Dec 6 00:37:30 PST 2011


Don:

>Right. But it's hard to come up with high-priority language issues these days. The old ones have been fixed. <g>.<

There are several things that I'd like to see fixed/improved in D still. In particular there are two holes from C language that have no place in D, I mean code like:

x = x++;

Or code like (bar and baz are not pure):

int z = 0;
int foo(int x, int y) { return x + y; }
int bar(int x) { z++; return x * x + z; }
int baz(int x) { z--; return 2 * x + z; }
int main() {
    int w = foo(bar(5), baz(3));
    return w;
}

See also:
http://en.wikipedia.org/wiki/Sequence_point

You can't remove all undefined behaviours from D, but they must be reduced and minimized, because D tries to lead to correct and deterministic programs.

A solution is to define the behaviour in those situations (and pay a bit of performance in some cases), an alternative is to statically forbid some kinds of code (and pay a bit of flexibility. C lints essentially forbid code like x=x++;), or a mix of the two solutions. (Forbidding something is not so bad because I've seen bad C code that mutates some variables inside a single expression, and it's code that is not easy to understand and it's not easy to translate to other languages).

Bye,
bearophile


More information about the Digitalmars-d mailing list