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!postnews.google.com!e65g2000hsc.googlegroups.com!not-for-mail From: andrew Newsgroups: comp.lang.ada Subject: Re: Generic Collection Date: 10 May 2007 15:48:05 -0700 Organization: http://groups.google.com Message-ID: <1178837285.391940.192010@e65g2000hsc.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> NNTP-Posting-Host: 139.78.128.110 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1178837285 28101 127.0.0.1 (10 May 2007 22:48:05 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 10 May 2007 22:48:05 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: e65g2000hsc.googlegroups.com; posting-host=139.78.128.110; posting-account=Kq9unQ0AAADh_grEViI3JGqegXKDDjxt Xref: g2news1.google.com comp.lang.ada:15744 Date: 2007-05-10T15:48:05-07:00 List-Id: On May 10, 2:31 pm, Simon Wright wrote: > andrew writes: > > Since table, tuple and schema are collections I would expect them to > > have the same "capability". So I would expect to be able to add > > items, delete items, inspect individual items, change individual > > items, sort them, compare them to each other, search them, serialize > > individual items and serialize the whole collection. That's what I > > see for now. > > > There was a problem with my example. Here is the correction > > > attr1 : attribute; > > attr2 : attribute; > > attr3 : attribute; > > attr4 : attribute; > > attr5 : attribute; > > attr6 : attribute; > > > tuple1 : collection; > > tuple1.add(attr1); > > tuple1.add(attr2); > > tuple1.add(attr3); > > > tuple2 : collection; > > tuple2.add(attr4); > > tuple2.add(attr5); > > tuple2.add(attr6); > > > table1 : collection; > > table1.add(tuple1); > > ...add more tuples to table1 > > > table2 : collection; > > table2.add(tuple2); > > ...add more tuples to table2 > > > schema : collection; > > schema.add(table1); > > schema.add(table2); > > > 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. > > Do you want to be able to add attributes to schemas? I would have > thought not .. > > If you make all the classes extend the same type they you're likely to > end with run-time errors, which isn't really the Ada Way. > > I would have thought you'd want to be able to add Attributes to > Tuples, Tuples to Tables, and Tables to Schemas, and that you'd be > better off looking at overloading. > > procedure Add (To: in out Tuple; Item : Attribute); > procedure Add (To: in out Table; Item : Tuple); > procedure Add (To: in out Schema; Item : Table); > > If it was me I'd want to distinguish between the 'specification' > aspects defined in the schema and the 'dynamic' aspects defined in the > user data. Your setup seems to mix the two; a Specificaton_Table can > only ever have one Specification_Tuple which is going to define the > number and types of the attributes that each Dynamic_Tuple *must* have > in a (the?) corresponding Dynamic_Table.- Hide quoted text - > > - Show quoted text - So I think you are saying I would have one Collection package and it has three procedures called Add and they operate on three different types: Tuple Table Schema but then how do I later use the collection package for some other purpose? What if I want to add Colors to a collection? My goal would be to Add almost "anything" to the collection instance. Overloading only gives me the add methods for tuple, table and schema; I'd have to go implement another overload for colors IF colors, tuple, table, schema didn't extend some "Object" type for which all could be stored in the collection as "Object". I don't understand why I would have run-time errors. Please expand that thought.