Parallel Rogue-like benchmark

Marco Leise Marco.Leise at gmx.de
Thu Nov 7 07:03:20 PST 2013


Am Thu, 07 Nov 2013 15:27:57 +0100
schrieb "Daniel Davidson" <nospam at spam.com>:

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

Yes it is pedantic and I don't mind if anyone objects. :)

> 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

Data is either mutable or immutable. The way I see it, const
is just a bridge to combine both worlds when the context
allows for both mutable and immutable data.
Immutable by default would have made the code look less
pedantic, but I could imagine there are big downsides to that
as well.

-- 
Marco



More information about the Digitalmars-d mailing list