pure member functions
bearophile
bearophileHUGS at lycos.com
Sun Sep 19 17:19:00 PDT 2010
Jonathan M Davis:
> I assume that if you declare a member function as pure, then all of its
> parameters - including the invisible this - are included in that. That is, if
> all of them - including the invisible this - have the same value, then the
> result will be the same.
This D2 program runs with no errors, and here there isn't a D language/compiler bug:
struct Foo {
int x;
this (int xx) { this.x = xx; }
pure int bar() { return x; }
}
void main() {
Foo f = Foo(1);
assert(f.bar() == 1);
f.x *= 2;
assert(f.bar() == 2);
}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list