Hello,
I read in the doc that pure functions can only accept invariant parameters, but
it seems that const parameters are also accepted by the compiler. For instance:
import std.stdio;
class A{
int x;
}
pure int f(const A a){
//- as const is transitive, we cannot modify any part of 'a' from here.
// b u t:
//- as 'a' is not invariant, it may be changed in the same time by a non
constant view of this
// same data
return a.x;
}
void main(){
A a= new A; //a is not invariant
writefln(f(a));
}
So why is this code accepted by the compiler?