

72·
11 days agoWhat you need here is not the stability in memory (i.e. of pointers, which you lose when you recreate an object) but instead just the stability of an identifier (e.g. the index into a list).
What you need here is not the stability in memory (i.e. of pointers, which you lose when you recreate an object) but instead just the stability of an identifier (e.g. the index into a list).
That’s the point, when programming with immutable structures you always pass the mutability onto the enclosing structure.
A list is an antipattern here IMO. Just wrap it in some dedicated object (see e.g. Java’s
StringBuilder
).