In an imperative, object orients language, would make more sense to have mutable or immutable closures?
For example:
int i=5;
function() f={print(i);};
f();
i=6;
f();
If the closure is mutable, this would print:
5
6
If it is immutable, it would print:
5
5
I realize that even with immutable closures, you could still do this:
class I {int i;}
I i=new I();
i.i=5;
function() f={
I j=i;
print(j.i);
};
f();
i.i=6;
f();
So, would it be better to have mutable, or immutable closures, or have the option for both? Immutable closures seem easier to implement, so at this point, I think I'll go with that, unless there is a good reason not to.