maarten van damme:
Is there a special reason I should use them in little programs
like these?
In my experience small programs contain lot of the issues and
ideas contained in large programs. Using things like "pure" and
"const/immutable" helps avoid/catch some bugs even in small
programs.
Generally try to make your code as strong as possible, to avoid
chances of introducing bugs.
I'm not all that familiar with __gshared, why does it increase
performance?
That implements global variables as in C. Take a look at the D
docs, about thread-local memory, etc.
Would performance increase be noticeable? I guess not.
In your code I have seen performance increase replacing ubyte[]
with bool[].
(using contracts is really something I should start doing...)
Yep. It's a matter of self-training.
I should also add a little check to see if every value I put is
indeed numerical.
That's very easy to do:
if (args[1].length != size || args[1].countchars("0-9") !=
args[1].length) {
writeln("A sudoku is 81 0-9 digits, not ",
args[1].length, " digits");
return;
}
Bye,
bearophile