Xref: utzoo comp.lang.misc:7231 comp.object:3001 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!uunet!cimshop!davidm From: cimshop!davidm@uunet.UU.NET (David S. Masterson) Newsgroups: comp.lang.misc,comp.object Subject: Re: CHALLENGE: heterogeneous collections Message-ID: Date: 2 Apr 91 06:47:16 GMT References: <1991Mar25.220525.11087@leland.Stanford.EDU> <521@eiffel.UUCP> Sender: davidm@cimshop.UUCP Distribution: comp Organization: Consilium Inc., Mountain View, California Lines: 55 In-reply-to: bertrand@eiffel.UUCP's message of 30 Mar 91 01:41:37 GMT >>>>> On 30 Mar 91 01:41:37 GMT, bertrand@eiffel.UUCP (Bertrand Meyer) said: > From by > cimshop!davidm@uunet.UU.NET (David S. Masterson): > [Quoting from my earlier posting:] > >> To handle heterogeneous collections without endangering static > >> typing, use genericity (Eiffel syntax): > >> class COLLECTION [G] ... > [Mr. Masterson's reply:] > > Is this a heterogeneous collection (one collection object > > containing many objects of many types) or a generic collection > > class (a collection class that may be defined to contain any > > *single* type of object [which may have multiple parent types])? > Although this is probably clear to most people reading this newsgroup, > it may be worth confirming that the collection described by the above > COLLECTION class is indeed heterogeneous (if so desired by > clients). I really hate the idea of contradicting Bertrand Meyer as I'm probably getting in over my head. However, I think there is a point that is being missed (and I'm probably the one missing it). I believe the original poster was looking for a use for a *truly* heterogeneous collection. From Mr. Meyer's description of COLLECTION (I don't know Eiffel), it still seems that this is more of a generic collection class in that all objects that can be contained in the collection are related through some (base) type and, therefore, follow some (base) protocol. Obviously, both C++ (through pointers to base class and polymorphism) and Smalltalk (because everything is ultimately an Object) have analogues to this. However, I think what is desired is something where objects in the collection are not related and, therefore, follow no set protocol. For instance, in the following: tax_collection: COLLECTION [TAX] users of the collection know that (at the very least) all objects obtained from the collection will follow the TAX object protocol. On the other hand: h_collection: COLLECTION [void] /* or is it 'void*'? */ might be a *truly* heterogeneous collection (assuming objects entered into the collection can be implicitly cast to VOID), but (going back to the original question) how useful would it be since all clues as to type and protocol of objects in the collection are removed? -- ==================================================================== David Masterson Consilium, Inc. (415) 691-6311 640 Clyde Ct. uunet!cimshop!davidm Mtn. View, CA 94043 ==================================================================== "If someone thinks they know what I said, then I didn't say it!"