Struct immutable data and dict

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 5 19:09:44 PDT 2016


On Thursday, 6 October 2016 at 01:23:35 UTC, Patric Dexheimer 
wrote:
> Why?

Because you'd be overwriting that immutable member. Structs just 
put structure around their contents, but it doesn't change their 
nature. That struct is no different than if you wrote `immutable 
size_t` as the value - and of course, overwriting that; changing 
that violates that promise that you won't change it.

You could store pointers to those structs though, and overwrite 
the pointer.


More information about the Digitalmars-d-learn mailing list