Unexpected behavior when casting away immutable
Dicebot via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Sep 23 07:59:43 PDT 2015
On Wednesday, 23 September 2015 at 14:34:07 UTC, bachmeier wrote:
> I was not aware that you could "violate" immutable. In that
> case, it's not immutable.
You can violate absolutely everything in a system language with
casts and pointers. That is exactly what makes it system
language. But you do so only by intentionally and explicitly
abandoning type system and domain of well-defined behaviour.
Compiler could as well decide to put it in RO section of
executable resulting in app crash at runtime (that happens with
string literals on Linux). Any cast means "I know what I am doing
and I am fully prepared to get burned".
More information about the Digitalmars-d-learn
mailing list