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=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,20b3b2fc48674108 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-03 12:26:18 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!62.112.0.25!newsfeed.online.be!isdnet!psinet-france!psiuk-f4!psiuk-p4!uknet!psiuk-n!news.pace.co.uk!nh.pace.co.uk!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: Preferred method for bringing in operators Date: Tue, 3 Jul 2001 15:04:42 -0400 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: <9ht50b$dk6$1@nh.pace.co.uk> References: <9hsnkr$90q$1@nh.pace.co.uk> NNTP-Posting-Host: 136.170.200.133 X-Trace: nh.pace.co.uk 994187082 13958 136.170.200.133 (3 Jul 2001 19:04:43 GMT) X-Complaints-To: newsmaster@pace.co.uk NNTP-Posting-Date: 3 Jul 2001 19:04:43 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:9394 Date: 2001-07-03T19:04:43+00:00 List-Id: Yeah. That generates some ideas at least. Out of all the possible approaches, this is one of them! :-) I'm dealing basically with a tagged record and working from the polymorophic approach. Its not that I don't like generics - its just that in this case I want to be able to keep extending the classes to have new features as the need arises & generics tend to be less amenable to this. Besides, from looking at your generic example, I can see what I dislike about the approach - the need to build long lists of generic formal parameters and the difficulty this implies for the end-user. It has its advantages in many cases, but I'd like to avoid it if possible. Still, if all I want is to get a user defined "<" operator, this isn't so bad. I'm just not sure that it is the "Object Oriented Ada Way" - or at least a way that one won't regret as one uses and extends the package. On another matter: It looks like you're doing some things similar to things I have attempted - deriving tagged types from Ada.Finalization.Controlled. I'm using Gnat 3.13p and have had trouble mixing this with various stream operations. (What would appear to be legal & workable when it *doesn't* derive from Finalization ends up crashing when it *does* derive from Finalization.) I'm wondering if you have experienced similar troubles and if so did you find a workaround? Are there other Ada compilers on which this may have worked properly? MDC -- Marin David Condic Senior Software Engineer Pace Micro Technology Americas www.pacemicro.com Enabling the digital revolution e-Mail: marin.condic@pacemicro.com Web: http://www.mcondic.com/ "Stephen Leake" wrote in message news:uith9nbra.fsf@gsfc.nasa.gov... > "Marin David Condic" writes: > > > This is a question about style and preferences, rather than something purely > > technical. I just want to know what people prefer and if there are any > > reasons to consider one style superior to another... > > > > Suppose you build a class to represent a container of some objects. The > > objects are just stored and retrieved from the container in no particular > > order. Now you want to derive a child class from the container only in this > > case you want to store and retrieve the objects in sorted order. That means > > you have to somehow extend the class to bring in one or more comparison > > operations for the object being stored. A variety of solutions exist: > > > > You first need to decide if you are using a tagged type approach, or a > generic approach. Since you said "class", I guess you are leaning > towards tagged types, but then you talk about generics, so I'm > not clear. > > For my answer to both approaches, see > http://users.erols.com/leakstan/Stephe/Ada/sal.html > > Specifically, for the generic approach, sal-gen-alg.ads defines the > notion of an algoirthm on a container, sal-gen-alg-find_linear.ads > extends that to a 'find' alorgithm. Then > sal-gen-alg-find_linear-sorted.ads extends that to a linear sorted > list, and sal-gen-alg-find_binary.ads extends it to binary searching > on a sorted container. > > For the tagged type approach, see sal-poly-alg.ads, > sal-poly-alg-find_linear.ads. These are also generics, but the basic > container is a tagged type. > > Hope this helps :). > > -- > -- Stephe