On Thu, 11 Aug 2005 01:19:19 +0100 phil hunt wrote: > According to Wikipedia, the Liskov substitution principle is: > > Let q(x) be a property provable about objects x of type T. Then > q(y) should be true for objects y of type S where S is a subtype of T > > To me, this is nonsense. Under this definition any subtype must > behave the same as its parent type, becausde if it doesn't there > will be some q(y) that are different to q(x). > > But if it behaves the same, what's the point of having a subtype?
It does not behave the same, it has the same properties. In other words, if there is some true assertion about _any_ object of type x, then it's true about any object of type y, if y is derived from x. Quick-and-dirty example: any object of type "list" is iterable, and it is true as well for any object of some type derived from list. -- jk -- http://mail.python.org/mailman/listinfo/python-list