Xref: utzoo comp.lang.eiffel:1347 comp.object:2470 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!lll-winken!ames!ads.com!saturn!doug From: doug@saturn.ads.com (Doug Morgan) Newsgroups: comp.lang.eiffel,comp.object Subject: Re: Inheritance and Information Hiding Message-ID: Date: 31 Jan 91 19:45:24 GMT References: <1991Jan23.224203.3206@runx.oz.au> <1991Jan24.214652.18515@Think.COM> <10612@pasteur.Berkeley.EDU> <485@eiffel.UUCP> <488@eiffel.UUCP> Sender: usenet@ads.com (USENET News) Organization: Advanced Decision Systems, Mountain View, CA 94043, +1 (415) 960-7300 Lines: 39 In-Reply-To: bertrand@eiffel.UUCP's message of 31 Jan 91 03:12:32 GMT In article <488@eiffel.UUCP> bertrand@eiffel.UUCP (Bertrand Meyer) writes: Will anyone take up the simplest example (discussed in my posting <485@eiffel.UUCP>): a class POLYGON exists and has a procedure ``add_vertex'', which it exports. You want to add a class RECTANGLE. What do you do? 1. ... 2. ... 3. ... 4. Accept that RECTANGLE inherits from POLYGON and does not export ``add_vertex''. Permit polymorphic assignments of the above form; but have the type checker reject as invalid any system which would contain both such an assignment and a call p.add_vertex (...), since it may lead to a run-time inconsistency. Do not introduce any distinction between ``implementation inheritance'' and any other kind. ... I would be interested to see any ... alternative solutions ... -- -- Bertrand Meyer bertrand@eiffel.com 4. is a bit strict for my taste. I wouldn't mind it as a option, however. I like being able to do this (say, in CLOS): 5. Accept that RECTANGLE inherits from POLYGON and *does* export ``add_vertex''. Permit polymorphic assignments of the form p := r where p is of type POLYGON and r of type RECTANGLE and have a subsequent call of p.add_vertex (...) convert the current RECTANGLE implementation (and class) of object p to a POLYGON implementation (and class). Of course, for this example I changed the "invariants" for the RECTANGLE class. They are not unreasonable, just beyond the compile-time restrictions of Eiffel. Doug Morgan doug@ads.com