‹ BackHN Continuity

Thread

Why isn't mutable a subtype of immutable, or vice versa?

28 points · 56 comments · ibobev

  1. MiroslavPokorny · · focus · HN ↗
    Because if mutable is a sub type of immutable, it wouldnt be right to give a mutable value when the receiver expected immutable values. The same is also true if one reverses the relationship, the mutable operations should not be defined on the immutable, and if they were that would be dumb because the immutable implementations should fail, which is silly.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.