Path: utzoo!dciem!nrcaer!sce!cognos!alanm From: alanm@cognos.uucp (Alan Myrvold) Newsgroups: comp.lang.eiffel Subject: Re: generic parameters Message-ID: <4913@cognos.UUCP> Date: 21 Dec 88 20:19:42 GMT Article-I.D.: cognos.4913 References: <1826@vlot.cs.vu.nl> Reply-To: alanm@cognos.UUCP (Alan Myrvold) Organization: Cognos Inc., Ottawa, Canada Lines: 49 In article <1826@vlot.cs.vu.nl> jos@cs.vu.nl () writes: >I have some questions about the usage of generic parameters. > >WINDOW inherits class TREE, but it does not specify the generic >parameter of TREE. > >Questions: > > 1. Is this correct Eiffel? (I can't find anything in the book about it) No, the syntax error generated by the compiler is something like: "window", 3: Wrong number of generic parameters for parent class: tree > If we have an object w of type WINDOW, then w.child should be > the same as w.child_value. This looks suspicious, so I think > this is not the right solution. I'm not an eiffel expert (yet) but .... In eiffel, specialization can be done via inheritance and by parameterizing generic classes. You may want to re-read sections 19.3 and 19.4 in Meyer's book. 19.3 Simulating inheritance with genericity. 19.4 Simulating genericity with inheritance. In the windows example, we want "a window IS A tree", so if there was a non-parameterized version of tree we could inherit it and do our work. Alternatively, we could have, say an object called "screen" (which may contain a tree of windows) become a client of a parameterized version of tree. Now "a window IS NOT A tree", but each tree node points to a window. Inheriting AND parameterizing is overkill, which is why w.child is the same as w.child_value. It is not incorrect. Some times we will want the "IS A" relationship with a tree, and other times we will simply want to become a client of tree. So yet another example in eiffel where we are forced to ask ourselves: "Do we buy or inherit?" --- Alan Myrvold 3755 Riverside Dr. uunet!mitel!sce!cognos!alanm Cognos Incorporated P.O. Box 9707 alanm@cognos.uucp (613) 738-1440 x5530 Ottawa, Ontario CANADA K1G 3N3