On Tuesday, 17 January 2012 at 05:16:33 UTC, H. S. Teoh wrote:
The following code compiles without error:
class C {
int x;
// what does 'pure void' mean??
pure void f() {
x++; // why is this legal?
}
}
What does 'pure' mean when applied to a member function?
This is a weakly pure function usable by strongly pure functions.
Namely it is a helper function to those that can claim to be
strongly pure.
Maybe bearophile's blog will shed some light:
http://leonardo-m.livejournal.com/99194.html
Or stackoverflow:
http://stackoverflow.com/questions/5812186/pure-functional-programming-in-d
Furthermore, what on earth is 'pure void' supposed to
mean and why does the compiler accept it?
Well it can only be useful as a weakly pure function as those are
allowed to modify their arguments.
In any case, if the function was strongly pure:
pure void foo() {}
any call to it would just be eliminated as having no side effects.