Why isn't mutable a subtype of immutable, or vice versa?
Thread
Unofficial Hacker News client; not affiliated with Y Combinator.
Why isn't mutable a subtype of immutable, or vice versa?
Unofficial Hacker News client; not affiliated with Y Combinator.
BlackFly · · focus · HN ↗
So mutability xor aliasing provides this strict subtyping relation. Of course, you also then need ways of loosening this by providing objects without such a contract and you enter the land of interior mutability, where again the mutable methods can be understood as a part of a subtype because a holder of the reference without mutable methods was explicitly told that there was no the guarantee that the object wouldn't change.