I appreciate Scala and I have a problem with its immutable collections.
I want to make immutable collections that are completely immutable, down to all contained objects, the objects that they reference, to infinity.
Is there an easy way to do this?
The code http://www.finalcog.com/immutable-containers-scala illustrates what I am trying to achieve and the nasty work (ImmutablePoint).
The problem with the workaround is that every time I want to change the object, I have to manually create a new copy. I understand that the runtime will need to implement copy-on-write, but can it be transparent to the developer?
I suppose I want to make Immutable Objects, where the methods change the current state of the object, but all the other "val" references (and all immutable containers) to the object retain the "old" state.
immutability scala functional-programming scala-collections
fadedbee
source share