next up previous contents
Next: Subclasses do not generate Up: Typing in object-oriented languages: Previous: Matching is necessary in

Binary methods complicate subtyping

  While the use of MyType provides us with a great deal of flexibility, there is one negative consequence of its use that we hinted at earlier. The problem arises with the binary methods discussed earlier. We can now describe these more precisely as methods that contain a parameter of type MyType. The methods ${\it {attachRight}}$, ${\it {setNext}}$, and ${\it {setPrev}}$ from the ${\it {Node}}$ and ${\it {DoubleNode}}$ classes in Section 5 are examples of binary methods. Other familiar examples include methods ${\it {equal}}$ and ${\it {lessThan}}$ that would require a parameter of the same type as the receiver, and then return Boolean values.



 

Kim Bruce
10/28/1998