From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,86a457a80a9f4412 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!proxad.net!proxad.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Generic Collection From: Georg Bauhaus In-Reply-To: <1178916106.931240.40880@p77g2000hsh.googlegroups.com> References: <1178652593.006083.173150@l77g2000hsb.googlegroups.com> <1178658022.9164.17.camel@kartoffel> <1178661586.585164.191690@e51g2000hsg.googlegroups.com> <1178722277.733981.6200@l77g2000hsb.googlegroups.com> <1178727131.9164.38.camel@kartoffel> <1178736886.994385.37140@y80g2000hsf.googlegroups.com> <1178837285.391940.192010@e65g2000hsc.googlegroups.com> <1178871050.6451.13.camel@localhost.localdomain> <1178916106.931240.40880@p77g2000hsh.googlegroups.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: # Message-Id: <1178918914.8423.47.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Date: Fri, 11 May 2007 23:28:34 +0200 NNTP-Posting-Date: 11 May 2007 23:28:35 CEST NNTP-Posting-Host: 50817e5b.newsspool4.arcor-online.net X-Trace: DXC=kKGZQ:jRRka016@cHD@m;j4IUK On Fri, 2007-05-11 at 13:41 -0700, andrew wrote: > On May 11, 3:10 am, Georg Bauhaus wrote: > > On Thu, 2007-05-10 at 15:48 -0700, andrew wrote: > > > On May 10, 2:31 pm, Simon Wright wrote: > > > > > So, I'm thinking that many of the "capabilities" or operations I > > > > > desire of the collection would have to be "dispatching" to the type of > > > > > the collection object. > > > > When is the type of the collection object determined? How? > The statement I made may be misleading. It's not dispatching on the > type of the collection object but on the type of the object stored in > the collection. Does that make better sense? OK. tuples: collection; tables: collection; declare item: ? := get(tables, key); If you don't care that there is only one type of collection for all kinds of objects, then indeed references to DB_thing'class objects seem a plausible choice for storing table objects in collection. Where type DB_thing is abstract tagged private; type DB_thing_ref is access DB_thing'class; type attribute is new DB_thing with private; type tuple is new DB_thing with private; ... package DB_collections is new Containers.Hashed_Sets (Element_Type => DB_thing_ref, ...); subtype collection is DB_collections.Set; Is there really a sufficiently common algorithm for schemas, tables, tuples, and attributes? > > If you want a collection that doesn't collect either Apples > > or Oranges, but instead is capable of holding Apples, Oranges, > > Cabbage, Motor_Oil, Whatever, you can have that, too. Is this > > what you want? > Yes, but I wouldn't really be storing apples, oranges, cabbage, ... I > would be storing a common object type like "Object". Right? Right. > > > I don't understand why I would have run-time errors. Please expand > > > that thought. > > > > Just think of the consequences of Java pre-1.5 collections delivering > > nothing but Object objects. > There was a problem with delivering objects of type Object? Yes, there was a problem with everything being of type Object. For example, retrieving references from collections forces type checking at run time and throwing ClassCastException when there is a mismatch. some_ref = (IKnowWhatType) container.get(some_key); That is a reason why Java now has generics.