Xref: utzoo comp.object:3349 comp.lang.eiffel:1536 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!wuarchive!psuvax1!news From: schwartz@groucho.cs.psu.edu (Scott Schwartz) Newsgroups: comp.object,comp.lang.eiffel Subject: Re: Unification: Class=Type=Module Message-ID: Date: 25 Apr 91 07:04:02 GMT References: <1991Apr23.142800.12215@bony1.bony.com> Sender: news@cs.psu.edu (Usenet) Organization: penn state university, computer science Lines: 40 In-Reply-To: richieb@bony1.bony.com's message of 23 Apr 91 14:28:00 GMT Nntp-Posting-Host: groucho.cs.psu.edu richieb@bony1.bony.com (Richard Bielak) writes: | One of the things I liked about "Object Oriented Software Construction" | by B. Meyer, was the idea that a class is both a type and a module. | This idea clears up the confusion as to whether inheritance extends or | specializes. | | When a class is considered to be a type, inheritance specializes the | type. The descendent type is type-compatible with fewer things, so it | is more specialized. | | When a class is considered to be a module, inheritance adds more | routines and attributes. Since the class can do more things it has | been extended. | | I also like the "cleanness" and simplicity of this idea. | | I am curious whether other people think about this, and whether such | "unification" has any disadvantages. Since no one else has stood forth on the issue, I will. (Let me admit in advance that I've never written an Eiffel program in my life; these comments are motivated by experience with C++. If a free eiffel compiler were available, I'd probably use it.) I don't much like using classes as modules. They seem well suited to building abstract data types, which means they do some encapsulation, but that is no substitute for a real package system that lets you encapsulate a group of ATDs. You mention two ways to use inheritance. It seems to me that these two goals often get in each other's way; as a result there is real disagreement on what inheritance is all about (I recall a paper "inheritance is not subtyping" in a recent TOPLAS, for example.) Eiffel's use of covariance and conditional assignment makes the kind of extensibility that class-as-module requires possible -- it's much harder in C++ where both of those are forbidden by the type system. I feel like modularization is more useful than subtyping. In that light, I agree with lots of Wirth's design choices in Oberon.