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
On Wednesday, 23 September 2015 at 14:34:07 UTC, bachmeier wrote:
On Wednesday, 23 September 2015 at 05:24:05 UTC, John Colvin
wrote:
violating immutable is undefined behaviour, so the compiler is
technically speaking free to assume it never happens. At the
very least, neither snippet's resul
On Wednesday, 23 September 2015 at 05:24:05 UTC, John Colvin
wrote:
violating immutable is undefined behaviour, so the compiler is
technically speaking free to assume it never happens. At the
very least, neither snippet's result is guaranteed to show a
change or not. At the most, literally an
On Wednesday, 23 September 2015 at 11:38:38 UTC, Mafi wrote:
On Wednesday, 23 September 2015 at 05:24:05 UTC, John Colvin
wrote:
On Wednesday, 23 September 2015 at 03:39:02 UTC, Mike Parker
wrote:
...
```
immutable int x = 10;
int* px = cast(int*)&x;
*px = 9;
writeln(x);
```
It prints 10, wh
On Wednesday, 23 September 2015 at 05:24:05 UTC, John Colvin
wrote:
On Wednesday, 23 September 2015 at 03:39:02 UTC, Mike Parker
wrote:
...
```
immutable int x = 10;
int* px = cast(int*)&x;
*px = 9;
writeln(x);
```
It prints 10, where I expected 9. This is on Windows. I'm
curious if anyone k
On Wednesday, 23 September 2015 at 03:39:02 UTC, Mike Parker
wrote:
I have a situation where I would like to demonstrate violating
the contract of immutable (as an example of what not to do),
but do so without using structs or classes, just basic types
and pointers. The following snippet works
On Wednesday, 23 September 2015 at 03:50:44 UTC, Vladimir
Panteleev wrote:
On Wednesday, 23 September 2015 at 03:39:02 UTC, Mike Parker
wrote:
```
immutable int x = 10;
int* px = cast(int*)&x;
*px = 9;
writeln(x);
```
It prints 10, where I expected 9. This is on Windows. I'm
curious if anyone
On Wednesday, 23 September 2015 at 03:39:02 UTC, Mike Parker
wrote:
```
immutable int x = 10;
int* px = cast(int*)&x;
*px = 9;
writeln(x);
```
It prints 10, where I expected 9. This is on Windows. I'm
curious if anyone knows why it happens.
Essentially, because x is immutable, the compiler op
I have a situation where I would like to demonstrate violating
the contract of immutable (as an example of what not to do), but
do so without using structs or classes, just basic types and
pointers. The following snippet works as I would expect:
```
immutable int i = 10;
immutable(int*) pi = &