|
|
|
|
|
by zactato
426 days ago
|
|
I've always thought that there should be mutability of objects within the function that created them, but immutability once the object is returned. Ultimately one of the major goals of immutability is isolation of side effects. |
|
Maybe I'm discarding this too readily, but I don't think this idea of "local mutability" has much value -- if an object is mutable, the compiler and runtime has to support mutation and many optimizations are impossible because every object is mutable somewhere during their lifetime (and for objects created in main, they're mutable for the lifetime of the program).