5 ms·
> In this case, {x: int, y: int, z: int} is a subtype of {x: int, y: int} It seems like the former should be a supertype?
by smitty1e 2y ago
> In this case, {x: int, y: int, z: int} is a subtype of {x: int, y: int}
It seems like the former should be a supertype?
- almostgotcaught 2y agoGeneral -> specific Animal -> Dog (and a Dog will have more fields than an animal)
- smitty1e 2y agoAh, so. That helps. Thank you.
- jraph 2y agoNo, because all {x, y, z}s are {x, y}s, but the opposite is not true. Said differently, any function that applies to the general {x, y} also applies to the more specific {x, y, z} (it will just not use the z part) but a function that requires a {x, y, z} specifically will not work with all {x, y}s.
- yxhuvud 2y agoIn any case, it is clearly not following from his definitions of what a subtype is, since as soon as something depends on memory size the interopability is lost.
- kragen 2y agoNot necessarily? Usually the only operation that depends on memory size is constructing a new object of a type. With respect to memory size, operations on existing objects only depend on the memory size being at least big enough, other than maybe things like .clone().