Vision for the D language - stabilizing complexity?

Mike Parker via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 15 09:01:26 PDT 2016


On Friday, 15 July 2016 at 15:35:37 UTC, Dicebot wrote:

>> One example is if you make a class that has an internal cache 
>> of something. Updating or invalidating that cache has no 
>> logical effect on the externally-observable state of the 
>> class. So you should be able to modify the cache even on a 
>> 'const' object. This is not a bug and I've seen it have a huge 
>> effect on performance - probably a lot more than the const 
>> optimizations Walter is talking about here.
>
> Yes and the fact that D prohibits this incredibly common C++ 
> design anti-pattern makes me very grateful about such choice. 
> Logical const is terrible - either don't mark such objects as 
> const or make cache separate.

+1

Use an interface that prevents external modifications, e.g. 
getters, but no setters.


More information about the Digitalmars-d mailing list