In D, if a function is pure, can it call a function that modifies global state?
That is to say (in not necessarily real D, just close enough) given:
int global_var
void modify_global(int z) {
global_var += z;
return global_var;
}
pure int foo(int x) {
return x + modify_global(2);
}
What happens? Does the compiler barf because it causes modification to something not passed? If so, assuming that you can only modify the object passed (via methods of it, and presumably, the things that object points to in its members),then it maintains something much closer to referential transparency than you are implying.