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!y80g2000hsf.googlegroups.com!not-for-mail From: andrew Newsgroups: comp.lang.ada Subject: Re: Generic Collection Date: 14 May 2007 10:09:40 -0700 Organization: http://groups.google.com Message-ID: <1179162580.571056.73590@y80g2000hsf.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> NNTP-Posting-Host: 139.78.128.110 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1179162581 22291 127.0.0.1 (14 May 2007 17:09:41 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 14 May 2007 17:09:41 +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: y80g2000hsf.googlegroups.com; posting-host=139.78.128.110; posting-account=Kq9unQ0AAADh_grEViI3JGqegXKDDjxt Xref: g2news1.google.com comp.lang.ada:15793 Date: 2007-05-14T10:09:40-07:00 List-Id: On May 12, 2:18 am, Simon Wright wrote: > andrew writes: > > 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? > > I would probably end up with a package for each, with appropriate Add > operations. > > with Tuples; > package Tables is > type Table is private; > procedure Add (To : in out Table; Item : Tuples.Tuple); > ... > private > ... > package Tuple_Containers > is new (Items => Tuples.Tuple); > type Table is record > Items : Tuple_Containers.Container; > ... > end record; > ... > > where you get the fun of choosing which generic-container-package to > use (Ada.Containers would be a good start) or writing your own. > > I can't see what possible advantage you'd get from being able to add a > Colour to a Schema! If you make a container that can contain anything > you will need to have runtime checks to enforce this sort of rule > rather than compile-time checks. Elsewhere in this thread you seemed > to scoff at this as being a concern; I think classwide programming > ought to be restricted to the places where it brings you an advantage > rather than being something that makes your life difficult. I'm not sure you understand what I'm trying to achieve. In fact, sometimes even 'I' am not sure what I am trying to achieve. Basically (outside the scope of Ada) I just want a reusable "package" or "class" or "thing" that provides common procedures, functions to operate on a collection of like-typed things. Visual Basic .Net has one called just that; collection. Why should I expect not to have one when I use Ada? I want to use it for a multitude of things not just attributes, tables, tuples or schemas. I just used those as an example and that may be where the confusion comes in. Due to the fact that I am not an Ada expert things like "If you make a container that can contain anything you will need to have runtime checks to enforce this sort of rule rather than compile-time checks" means little to me in a visual sense; I have no refrence to know what the heck you are talking about. Although I think someone posted something recently when we were discussing Java's past use of Object. Maybe that is what you are referring to. Not only that but I'm not yet an avid user of generics and I'm quite certain that my level of understanding of generics will be a barrier for you. I won't appologize for that; it's just the way it is. To me, it makes little sense to make Table, Tuple and Schema a seperate class or package for each one. They _abstractly_ are a collection. A tuple is a collection of attributes, a table is a collection of tuples and a schema is a collection of tables. So really the only one that is different is tuple and it's different only in the type of the thing in the collection. Table and Schema are "collections of collections". To test if they are equal would have to be an opperation of the "thing" that is stored in the collection. An instance of collection should be able to call "=" if it's defined on the item in the collection right? For that matter any "comparative" operator defined on the thing in the collection should be accessible; at least that's what I envision at this time. Obviously the collection would have to have it's own comparative operators defined because we might want to compare two collections. If we cannot forecast the types of the things stored to be able to have a comparative operator defined for them then maybe the stipulation could be made that comparing collections doesn't descend into comparing the thing that the collection stores. That would have to be a auxillary algorithm for the user to implement because there is no way to be able to forecast what "things" are stored in each collection nor how to compare them if no comparative operators are defined OR they don't have a common base type. So why would we need to give the collection the ability to call the "=" operator of the things it stores if we agree that the collection isn't going to descend into comparing the thing that the collection stores? Well, I can only say that the stipulation applies only to the situation where we compare collections. The collection may have need to call the "=" operator on the thing it stores to do something like sort them but not need it for collection to collection comparissons. So I said all that stuff "my way". It's probably exactly what you are trying to tell me. Just be patient; I'll get it.