4 ms·
Not to be a pedant, but wouldn't thread-safe automatically follow immutable? If a structure is immutable, how would you be able to fuck it up, even if you abus
by josteink 14y ago
Not to be a pedant, but wouldn't thread-safe automatically follow immutable?
If a structure is immutable, how would you be able to fuck it up, even if you abuse it via threading? I would argue the relation is so strong, that something which isn't thread-safe cannot be immutable. But there may ofcourse be something which I'm missing.
Different languages and platforms handling different key concepts differently etc.
Is there some properties of Ruby which makes this possible, or gives you a need for a double-guarantee, or is the declaration here simply redundant?
- deleted 14y ago[deleted]
- asynchrony 14y agoConsider a balanced tree that only exposes an immutable interface but uses destructive updates internally when rebalancing. In principle it would be immutable, though it wouldn't necessarily be threadsafe without additional work.
- josteink 14y agoFrom my point of view, that would not be something I considered a immutable data-structure. But I guess at this point we are starting to argue technicalities and it's getting quite outside the scope of this submission. I'll just take a mental note with regard to immutable evidently being a lossy concept ;)
- dlikhten 14y agoImmutable simply means there is no way to change the data once you are given the object. That does not mean the impl is a clone. In any case, ruby is really missing something as good as this. Very nice stuff. Wish that it did not require "new" syntax compared to ruby's nice [ ] and { }. But whatever. This is a problem that will exist on any collection innovation.