Why is there Immutable and Persistent separation i...
# stdlib
p
Why is there Immutable and Persistent separation in kotlinx-collections-immutable? Why not to keep only Immutable interface?
z
They mean different things. Immutable means your reference to the collection is guaranteed not to change. Persistent means that, when you change the structure by making a copy of it, parts of the data structure are reused.
Immutability is the more important guarantee for correctness, persistence is a memory and space optimization
p
Hello, Zach! What do you mean by saying: parts of the data structure are reused? Isn't it implementation details (but both are interfaces)? As i thought both Immutable and Persistent collections make guarantee that they can't be modified.
e
the way persistent collections are implemented come with different complexity trade-offs than immutable collections that do not need to be persistent
the library doesn't currently make use of that, but it's in the roadmap to figure out https://github.com/Kotlin/kotlinx.collections.immutable/issues/185
p
@ephemient thanks for the link!