Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!sun-barr!newstop!exodus!red-dwarf!pallas From: pallas@eng.sun.com (Joseph Pallas) Newsgroups: comp.lang.misc Subject: Re: CHALLENGE: heterogeneous collections Message-ID: Date: 1 Apr 91 18:36:48 GMT References: Sender: news@exodus.Eng.Sun.COM Lines: 45 In marcs@slc.com (Marc San Soucie) writes of my definition of heterogeneous collections: >This is pretty left-field thinking. A collection is an entity, not an >activity. The collection exists regardless of what you do or whether >you do anything with it. So argue the definition of the entity, not >the operations that are to be performed on it or its members. Now, I have to admit that, at first glance, it may seem odd that the definition I offered has this dependency. But I think I can explain why it does. We all seem to agree that "heterogeneous" has something to do with the types of objects. The problem arises from the very nature of OOP in that it emphasizes inclusion polymorphism (usually in the form of subtypes). The consequence of this is that it is not possible in general to speak of "the type" of some object. Objects have many types, as the types are organized hierarchically in a containment relationship. Now, we can (as Marc pointed out) simply stop there and say that in Smalltalk, for example, there are no heterogeneous collections because there is a type of which all objects are members. But that clearly doesn't capture the notion we have in mind when we talk about heterogeneous collections. So, given a collection of objects and a desire to talk about the types of those objects, how do we decide which types to use? I claim that, in a dynamically typed language like Smalltalk, the only types we can sensibly use for this kind of discrimination are the types implied by the operations we actually perform. >How about a more accurate but possibly meaningless definition of a >heterogeneous collection: > A collection on the types of whose members there are no explicit > constraints. This isn't very interesting, since this definition makes all Smalltalk collections heterogeneous. It doesn't capture the common notion that collections are either homogeneous or heterogeneous. As for the question of whether this discussion is leading anywhere, I suspect not. joe