3 ms·
If I remember correctly, Liskov didn't talk about inheritance but subtyping in a more general way. Java, C++ and other, especially statically typed, compiled la
by zwieback 2y ago
If I remember correctly, Liskov didn't talk about inheritance but subtyping in a more general way. Java, C++ and other, especially statically typed, compiled languages often use inheritance to model subtyping but Liskov/Wing weren't making any statements about inheritance specifically.
- cratermoon 2y ago>subtyping in a more general way This is correct. I read her paper closely. One example I give is how SICP provides two implementations for complex numbers[1], the rectangular for and polar form. (make-rectangular (real-part z) (imag-part z)) and (make-polar (magnitude z) (angle z)) then on page 138 provides this interface that both satisfy (define (real-part obj) (operate 'real-part obj)) (define (imag-part obj) (operate 'imag-part obj)) (define (magnitude obj) (operate 'magnitude obj)) (define (angle obj) (operate 'angle obj)) 1 https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/full-text/book/book-Z-H-17.html#%_sec_2.4.1 https://mitp-content-server.mit.edu/books/content/sectbyfn/b...
- rramadass 2y ago> use inheritance to model subtyping but Liskov/Wing weren't making any statements about inheritance specifically. Right. Inheritance is just one mechanism to realize Subtyping. When done with proper contract guarantees (i.e. pre/post/inv clauses) it is a very powerful way to express semantic relationships through code reuse.