E-Ink News Daily

Back to list

FAQ: Why isn’t mutable a subtype of immutable, or vice versa?

This article explains why mutable and immutable variants of a data structure cannot be formal subtypes/supertypes of each other under Liskov's substitution principle. Using an immutable/mutable pair as a running example, it demonstrates that a mutable pair introduces operations (like set-car!/set-cdr!) that violate the behavioral contract expected of an immutable pair.

Background

The article discusses a recurring question in programming language design forums about type hierarchy between mutable and immutable data structures.

Source
Lobsters
Published
Sep 18, 2026 at 11:30 PM
Score
6.0 / 10