12 points ibobev 1 day ago 11 comments
gus_massa 12 hours ago | parent
comrade1234 1 hour ago | parent
catoc 1 hour ago | parent
Swift is completely different. Standard arrays are structures, always mutable - value types passed by value
bartvk 35 minutes ago | parent
Basically inheritance is the wrong tool for this kind of stuff. NSMutableArray inherits from NSArray, so it can be passed to anywhere NSArray is expected (upcasting).
So you design your classes and expect them to be immutable, but you can't use NSArray anywhere. Because otherwise, it'll be mutable after all. You can do a runtime check as a workaround.
(I truly believe OOP should only be taught in computer science as a relic).
nicky0 10 minutes ago | parent
zkmon 55 minutes ago | parent
Shorel 39 minutes ago | parent
https://commonplacefacts.com/2022/07/27/principia-mathematic...
applfanboysbgon 28 minutes ago | parent
Note, also, that the article isn't even objective. It asserts that the definition of a subtype is Liskov's principle. However, Liskov's principle is only one of multiple possible definitions. In other words, the article is really only invoking Liskov's name as an appeal to authority. So much for strict logic.
pestatije 24 minutes ago | parent
raincole 52 minutes ago | parent
In C# ReadOnlyCollection<T> and ImmutableArray<T> are two completely different things for this exact reason.
BlackFly 12 minutes ago | parent
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.