05.09.2019 17:31, berni пишет:
On Thursday, 5 September 2019 at 13:27:55 UTC, drug wrote:
[...]when you put it into an AA you modify old value
Why?!? :-o When putting it into an AA it will be copied to a different
place in memory, but the value is still the same, it's not modified.
Sorry, but I still think, there is something fundamentally wrong about
how I think about immutability.
Because structs are value types - assigning new value to old value means
the old value modification. In case of reference types like pointers or
classes assigning new value to old one also means modifying old value
but this old value is a reference to value so in case of reference types
only reference modified but the value isn't
But if you just want to initialize an AA by immutable members then
this can be usefull to read
https://dlang.org/spec/hash-map.html#runtime_initialization
Well, yes and no. I want to initialize an AA with structs that contain
immutable members. And that AA resides at runtime inside of a function
body. I don't see, how this can be done with he approach given by the
link. :-(