On 2013-04-08 14:52, Iain Buclaw wrote:
On 8 April 2013 13:25, Jacob Carlborg <[email protected] <mailto:[email protected]>> wrote:On 2013-04-08 10:29, Iain Buclaw wrote: This information could possibly be helpful. Though given that most of (gdc) codegen is on par with g++, there's probably not much on the list that isn't already detected by the backend optimisation passes. Multiple calls to pure functions could be cached. -- /Jacob Carlborg Not always, but in some circumstances, yes. --- struct Foo { int a = 0; pure int bar (immutable int x) { ++a; return x * 2; } } void main() { Foo f; int i = f.bar(2) + f.bar(2); assert (i == 8); assert (f.a == 2); }
I though that wasn't possible. What's the point of pure if that's possible? -- /Jacob Carlborg
