On Friday, 3 July 2015 at 11:08:46 UTC, Tofu Ninja wrote:
...

It even gives nice errors when you try to access mutable data

void main(string[] args){
        int x;
        auto foo() immutable{return x;}
}

Error: pure immutable nested function 'main.main.foo' cannot access mutable data 'x'

Const does not seem to work properly though...
void main(string[] args){
        int x = 0;
        auto foo() const{
                x++;
                return x;
        }
        writeln(foo()); // prints 1
}

Reply via email to