zkmon 8 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.

raincole 6 minutes ago

In other words, immutable != read only.

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

gus_massa 12 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.

comrade1234 43 minutes ago

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

  • catoc 15 minutes ago

    Yes, that’s ObjC, any NSMutableArray is an NSArray (and an NSObject) - classes passed by reference.

    Swift is completely different. Standard arrays are structures, always mutable - value types passed by value