Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!pt.cs.cmu.edu!pt!dld From: dld@F.GP.CS.CMU.EDU (David Detlefs) Newsgroups: comp.lang.eiffel Subject: Typing question in eiffel Message-ID: Date: 21 Apr 89 20:14:27 GMT Organization: CMU CS Department Lines: 41 I've just finished reading OOSC, and found it very interesting. If you believe in strong typing and inheritance, then, in my opinion, the most important remaining question on which there is reasonable disagreement is whether subclasses should have access to superclass implementations. I've tended towards the view that they shouldn't (or at least should be very careful when they do) based on arguments by Liskov, Snyder, and Stroustrup. Meyer makes a fairly strong case that I see as basically of the form "but if you allow it, look at all the neat things you can do!" And the things you can do are quite interesting. Having thrown in my capsule review, I have a question about Eiffel. Somewhere in the book there is reference to the "golden rule" of the Eiffel type system: on page 223, it says "Once a system has been compiled, there is no risk that a feature will ever be applied at run-time to an object that is not equipped to handle it." This is a laudable goal. My question is how this can be reconciled with the "orthoganility of information hiding" -- on page 272, we find that a descendant class B is allowed not to export to clients a feature f that its ancestor A does export. Now, if we have an entity x of static type A and dynamic type B, is x.f legal? If so, does this make sense, and why? It seems to me that if you create a B, allowing f to be invoked could violate B's representation invariant. (Consider a type A that is basically an integer. It is created with value 0, and offers "incr" and "incr_by_2" operations. Its rep invariant is that it is > 0. If B inherits from A, but only exports the create and incr_by_2, its invariant is that it is > 0 and divisible by 2. If you ever invoke incr on a B, you violate its invariant.) Can anyone clear this up for me? Thanks. Dave -- Dave Detlefs Any correlation between my employer's opinion Carnegie-Mellon CS and my own is statistical rather than causal, dld@cs.cmu.edu except in those cases where I have helped to form my employer's opinion. (Null disclaimer.) --