3 ms·
Because if they went and made immutability the default, they’d break a lot of existing code that depends on it behaving in a mutable manner.
by fnordsensei 6y ago
Because if they went and made immutability the default, they’d break a lot of existing code that depends on it behaving in a mutable manner.
- specialist 6y agoDuh. Thanks. Being tainted by tuples and records from other languages, the immutable bits didn't register. Sorry. Reading the proposal (TC39) explains all. https://github.com/tc39/proposal-record-tuple https://github.com/tc39/proposal-record-tuple Paraphrasing, if I understand TC39 correctly, an immutable map is a record and an immutable array is a tuple. Has a certain elegance. Nicely done. While I'm inclined to like TC39, I'll chew on it to be sure.
- fnordsensei 6y agoYeah seems so. It’s a shame that they can only be shallowly cast from mutable to immutable (and will even throw errors if non-primitive values are present). Seems like quite the limitation. And yeah, I’m all for immutability as a default, but breaking so pervasive an existing API is a lot of damage.