Other notes
Moritz Warning
oh at no.es
Sat Nov 24 17:50:50 PST 2007
bearophile Wrote:
> Here are few more notes on the D language, now I know it enough.
>
> 1) At the moment this isn't acceptable in D (but the compiler correctly gives an error instead of doing the wrong thing as some C compilers):
>
> if (0 < a < 5) writefln("***")
Looks like a nice feature. It may not result in complexity,
but in generalization. But it may be hard to implement...
> 2) This looks like a bug of DMD v1.023, x isn't initialized, and it prints like garbage:
>
> import std.stdio: writefln;
> void main(string[] args) {
> if (args.length > 1) {
> switch (args[1]) {
> int x = 1; // NOT initialized?
> case "1": writefln("1! x=", x); break;
> case "2": writefln("2! x=", x); break;
> }
> }
> }
This should be an syntax error, imho.
[snip]
> 3b) This D code lacks a ref, maybe the compiler can spot this bug (I have done a mistake like this in the past):
>
> int[10] array;
> foreach(i, el; array)
> el = i;
int[10] array;
foreach(i, inout el; array)
el = i;
Works. :)
>
[snip]
> 4) Every language feature adds complexity to the compiler, makes the language manual longer, requires programmers to remember more things, etc. [...]
Imho, that is not the case every time.
Features may also mean generalisation that elemitates complexity.
E.g. allowing to pass global&&compile time values to the compiler for
the "debug" and "version" keyword could be generalized and would therefore
satisfy a good amount of requested features and also remove keywords/documentation.
>
> Bye and thank you,
> bearophile
:-)
More information about the Digitalmars-d
mailing list