Xref: utzoo comp.lang.misc:7184 comp.object:2972 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!swrinde!mips!pacbell.com!ucsd!hub.ucsb.edu!eiffel!bertrand From: bertrand@eiffel.UUCP (Bertrand Meyer) Newsgroups: comp.lang.misc,comp.object Subject: Re: CHALLENGE: heterogeneous collections Summary: Object-oriented programming usually includes inheritance Message-ID: <521@eiffel.UUCP> Date: 30 Mar 91 01:41:37 GMT References: <1991Mar25.220525.11087@leland.Stanford.EDU> Distribution: comp Organization: Interactive Software Engineering, Santa Barbara CA Lines: 54 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])? > > Next contestant? 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). If a client declares tax_collection: COLLECTION [TAX] and then uses the routines of class COLLECTION to insert objects into `tax_collection' and retrieve them, these objects may be direct instances not just of class TAX but of any of its proper descendants. (``Proper descendant'' means direct or indirect heir, according to the inheritance relation.) This is a direct result of the type rules: if COLLECTION [G] has an insertion procedure put (new: G) is -- Add `new' to the collection do ... ensure has (new) end -- put then in a call of the form tax_collection.put (tx) the actual argument tx may be of any type which is a descendant of TAX. In different calls, we may use actual arguments of different types, inserting objects of different types into the same collection. -- -- Bertrand Meyer bertrand@eiffel.uucp