Re: Question about pure functions

2013-09-16 Thread Jonathan M Davis
On Monday, September 16, 2013 10:08:22 anonymous wrote: > Mark all parameters const to get a strong pure function. For > "this" const goes on the method: That's not actually enough. At present, in order for a function to be considered strongly pure, all of its parameters must be either immutable

Re: Question about pure functions

2013-09-16 Thread Bienlein
Mark all parameters const to get a strong pure function. For "this" const goes on the method: class Foo { int i = 0; void bar() const pure { // can't mutate i here } } See also: http://dlang.org/function.html#pure-functions I see, thanks a lot. I l

Re: Question about pure functions

2013-09-16 Thread anonymous
On Monday, 16 September 2013 at 07:01:52 UTC, Bienlein wrote: Hello, ich habe a pure method bar() in a class Foo: class Foo { int i = 0; void bar() pure { i++; } } main() { auto foo = new Foo(); foo.bar() } The pure me

Question about pure functions

2013-09-16 Thread Bienlein
Hello, ich habe a pure method bar() in a class Foo: class Foo { int i = 0; void bar() pure { i++; } } main() { auto foo = new Foo(); foo.bar() } The pure method bar changes the inst var i. Nevertheless, the code above c