Article View: comp.lang.misc
Article #3297Re: CHALLENGE: heterogeneous collections
From: Bertrand Meyer
Date: Sat, 30 Mar 1991 01:41
Date: Sat, 30 Mar 1991 01:41
54 lines
2359 bytes
2359 bytes
From <CIMSHOP!DAVIDM.91Mar28192651@uunet.UU.NET> 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
Technical Details
Message-ID:
<521@eiffel.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!swrinde!mips!pacbell.com!ucsd!hub.ucsb.edu!eiffel!bertrandReferences:
<1991Mar25.220525.11087@leland.Stanford.EDU> <CIMSHOP!DAVIDM.91Mar28192651@uunet.UU.NET>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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> <CIMSHOP!DAVIDM.91Mar28192651@uunet.UU.NET> Distribution: comp Organization: Interactive Software Engineering, Santa Barbara CA Lines: 54