To help LDC/GDC
Artur Skawina
art.08.09 at gmail.com
Tue Apr 9 03:13:20 PDT 2013
On 04/09/13 02:44, deadalnix wrote:
> On Monday, 8 April 2013 at 15:07:31 UTC, Jacob Carlborg wrote:
>> I though that wasn't possible. What's the point of pure if that's possible?
>
> You have to think that this is an hidden parameter. The function touch that parameter, no global state.
D's pure is horribly misnamed; nobody that's not already aware of the
D re-definition expects "pure" to mean what it currently does.
struct S {
int* p;
int f() pure @safe nothrow { return ++*p; }
}
int i = 1;
int main() {
auto s = S(&i);
assert(i==1);
auto r = s.f();
assert(r==2);
r = s.f();
assert(r==3);
assert(i==3);
return r;
}
That's not pure by any definition, and fixing it w/o impacting
valid cases would be non-trivial (think array members).
artur
More information about the Digitalmars-d
mailing list