Wait, isn’t that what
const int *x;
does? I.e. a pointer to a constant.In D, `immutable(int)* x` cannot be changed by any reference to the value.
If you deceive the compiler like that, it is entitled to hand you a broken executable :-/
Besides, I forgot to mention that D immutable data is inherently thread safe, no synchronization required. And you can have as many live references to it as you like.
Immutable data is part of D's support for functional programming.
const int world = 42;
const int const * const hello = &world ;
Apparently, you can be very const and `gcc -Wall -Wextra -std=c99` won't raise any complaints. const int * const hello = &world;
Secondly, what should the compiler complain about? You have a const int, and then a const pointer to const int, pointing to that first const int. What’s the problem?Thirdly, the latest C version supported by GCC is “-std=c17”.
even if I use a magnetic needle to change the bits in my RAM ? :)