Re:Immer is a library of persistent and immutable data struc...
by dfgdghdf on Thursday September 12, 2019 @04:35AM
(#20949294)
Should add that C++ has const, making some of this irrelevant. In the C++ case immutability is about making minor changes to a structure more efficient by reusing the previous version. This is only possible with immutability because you need to be sure that your "base" structure won't change underneath you!
Re:Immer is a library of persistent and immutable data struc...
by slavik81 on Thursday September 12, 2019 @04:54AM
(#20949404)
Can't copy-on-write achieve the same thing? If you keep a reference count, you can know whether it's safe to mutate the underlying data, or whether you need to make a copy first.
Re:Immer is a library of persistent and immutable data struc...
by heavenlyblue on Thursday September 12, 2019 @07:22AM
(#20950201)
Technically copy-on-write is an implementation detail.
It may or may not be implemented this way.
Re:Immer is a library of persistent and immutable data struc...
by slavik81 on Thursday September 12, 2019 @02:51PM
(#20954957)
I mean that CoW classes like Qt's QStringList do the same data sharing without being immutable.
In the OOP world, you might have a "getter" for a property (e.g. a list of some kind) that you don't want readers to be able to modify.
Perhaps "set" was a poor name here, since it usually means something else in a C++ context. I quite like "with".