To help LDC/GDC
Timon Gehr
timon.gehr at gmx.ch
Tue Apr 9 03:30:10 PDT 2013
On 04/09/2013 12:13 PM, Artur Skawina wrote:
> ...
> 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,
I'd counter that it is pure by the D definition.
More information about the Digitalmars-d
mailing list