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 like this pure feature and was already
disappointed. Scala doesn't have it (has to remain interoperable
with Java), so I was really happy to see it in D. Your answer
saved my day :-)

-- Bienlein

Reply via email to