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

crumbles.blog

11 points by ibobev 2 days ago


raincole - 39 minutes ago

In other words, immutable != read only.

In C# ReadOnlyCollection<T> and ImmutableArray<T> are two completely different things for this exact reason.

comrade1234 - an hour ago

Isn't NSMutableArray a subclass of NSArray in a few languages?

zkmon - 42 minutes ago

The fact that it requires so much explanation, indicates the level of degradation in the reasoning ability of the audience. A value of a subtype shall deliver all of the expectations of its super type, because it is wearing both the hats of super type and sub type.

gus_massa - 13 hours ago

Yep, I wondered that for a few optimizations in Racket. It's harder than it looks, probably something about covariant or contravariant types, I gave up.