On Thursday, 7 November 2013 at 13:12:56 UTC, bearophile wrote:
Marco Leise:

I made it idiomatic, D is on place 1 now by a big margin. See the
'ldc2' entry:
http://togototo.wordpress.com/2013/08/23/benchmarks-round-two-parallel-go-rust-d-scala-and-nimrod/

Very nice. I have made a more idiomatic version (in D global constants don't need to be IN_UPPERCASE), I have added few missing immutable annotations, and given the benchmark also counts line numbers, I have made the code a little more compact (particularly the struct definitions, but I have moves the then branch of some if on a new line, increasing the line count to make the code a little more readable, so it's not a unnaturally compact D code):

http://dpaste.dzfl.pl/d37ba995

Bye,
bearophile


Regarding what is idiomatic D, isn't `immutable x = rnd.next % levelSize;` pedantic.
Why not just go with `const x = rnd.next % levelSize;`

Any time the type is a fundamental type with no aliasing there is no sharing so the differentiation of immutable vs const is unnecessary. Might as well go with const. immutable says I or no-one else will change the value. But since no-one else can change the value it seems overkill, no?

Thanks
Dan

Reply via email to