mutable, const, immutable guidelines

Dicebot public at dicebot.lv
Wed Oct 16 12:12:47 PDT 2013


On Wednesday, 16 October 2013 at 19:06:06 UTC, Daniel Davidson 
wrote:
> I don't understand how it could be fine. As code grows it would 
> lead to people not adding useful members like history just 
> because of the huge repercussions.
>
> struct User {
>    immutable(Foo) foos;
> }
>
> How can I as a user adapt to that change? Before the change 
> assignment worked equally well among all of Mutable, Immutable, 
> Const. After that change any `foos ~= createFoo(...)` would 
> require change. And it is not clear what the change would be.

I think any usage of immutable with types/entities not initially 
designed for immutability is an potential mistake and in that 
sense it is good that change has broken the user code. Same goes 
for operating on immutable entity in generic code as if it is a 
value type without actually checking it via introspection.


More information about the Digitalmars-d-learn mailing list