On 07/09/2012 07:49 PM, Andrei Alexandrescu wrote:
On 7/9/12 12:34 PM, David Piepgrass wrote:
I guess D does not have 'mutable' (like C++) to override const on
methods?

It doesn't, which makes life difficult for certain idioms. On the
upside, you can assume more than C++ does about immutable data.

Caching anything slow-to-compute is my typical use case, and I
know a hashtable design where the getter will move whatever value at
finds to the front of a hash collision chain.

Yah, that won't be easy to implement. We have a couple of designs in
mind for "mutable", but didn't get to it. Regarding advantages, think of
this - if an immutable instance of your bring-to-front hashtable were
used by multiple threads it would fail because it's "lying" about its
being immutable. For now just don't use const for what ain't.


This is very inconvenient if the root of the class hierarchy uses it.

Reply via email to