-
Notifications
You must be signed in to change notification settings - Fork 65
Description
This issue implements a methodological refinement to the PersistentCollection interface to enhance API clarity and align with Kotlin standard library conventions.
Problem
The current PersistentCollection interface uses imperative verb forms (add, remove, clear) that mirror MutableCollection's API, creating semantic ambiguity. While MutableCollection methods perform in-place mutations, PersistentCollection methods return new instances. This behavioral difference is not surfaced at the API level, requiring developers to rely on documentation rather than self-documenting code.
Solution
Apply Kotlin's established naming pattern (like sort() vs sorted()) to distinguish mutating from non-mutating operations. The participial "-ing" suffix immediately communicates that operations produce new instances rather than altering existing state.
Implementation
Introduce new methods with participial naming and deprecate existing imperative verb methods with migration guidance.
PersistentCollection: add → adding, addAll → addingAll, remove → removing, removeAll → removingAll, retainAll → retainingAll, clear → cleared
PersistentList: add(index) → adding(index), addAll(index) → addingAll(index), set(index) → replacingAt(index), removeAt → removingAt
PersistentMap: put → putting, putAll → puttingAll, remove(key) → removing(key), remove(key, value) → removing(key, value), clear → cleared