Possible 'pure' bug with int[] slice. Programming in D page 174

Kagamin spam at here.lot
Wed Oct 8 08:48:12 UTC 2025


To be pedantic, strong purity requires immutable arguments, const 
are not enough:
```
void main()
{
	import std.stdio : writeln;

	int[] numbers = [5, 6, 7, 8, 9];
	writeln("numbers before: ", id(numbers));
	numbers[0]=1;
	writeln("numbers after : ", id(numbers));
}

const(int)[] id(const int[] p) pure
{
	return p;
}
```


More information about the Digitalmars-d-learn mailing list