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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1ce805592e46d231 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-04 11:35:37 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!enews.sgi.com!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail Message-ID: <3B951F33.927CA445@home.com> From: Mark Biggar X-Mailer: Mozilla 4.76 [en]C-{C-UDP; EBM-SONY1} (Win95; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: (elementary question) Test on type ? References: <9n24g4$17q$1@snipp.uninett.no> <9n279a$1ua$1@snipp.uninett.no> <3B94B4B4.CE1955D6@nbi.dk> <9n2ctk$36v$1@snipp.uninett.no> <9n2l16$bqv$1@nh.pace.co.uk> <9n2pka$e44$1@nh.pace.co.uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Tue, 04 Sep 2001 18:35:37 GMT NNTP-Posting-Host: 24.250.143.171 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 999628537 24.250.143.171 (Tue, 04 Sep 2001 11:35:37 PDT) NNTP-Posting-Date: Tue, 04 Sep 2001 11:35:37 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:12712 Date: 2001-09-04T18:35:37+00:00 List-Id: Marin David Condic wrote: > > O.K. O.K. O.K. - You got me there. But that's sort of a deeper technical > area than what I think the original question was aimed at. (Sounded more > like a newbie with a more basic question than might be answered by tagged > records) > > I'd agree that if Ada were more of a "purely OO language" it probably would > have started deriving all of its types from some base type & generic > parameters might have had more adaptable characteristics. Its been > frustrating for me to deal with certain math-oriented packages where I've > essentially had to create more-or-less identical code for integer types, > fixed types, floating types and decimal types. Lots of math can be done > sticking only to the operations common to all of the above and if they were > all derived from some class called "Scalar" (or had a suitable generic > formal) you could get there a lot easier. > > 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/ > > "Ted Dennison" wrote in message > news:le5l7.3173$4z.4905@www.newsranger.com... > > > > Actually it is doable, if the type in question is a tagged type. In that > case > > you can easily do something like: > > > > if Object_A in Parent_Type_X'class then .... > > > > The reason this won't work for Integer is that Integer isn't tagged. Thus: > > > > 1) You can't use 'Class on it (or a subtype of it). > > 2) You can't pass it into a routine that can also take other types for the > same > > parameter. > > > > I suppose you would be able to do that with Integer if Ada had a type > system > > where every type was derived from some common root type. I think there are > some > > languages out there that work that way. Ada just isn't one of them. > > You can do almost what you want using a generic package using a private generic type and explicitly defining the operators you want to use. For example if your package only needs "+", "*", "-", "=", "<". generic type Scalar is private; with function "+"(Left, Right: Scalar) return Scalar is <>; with function "="(Left, Right: Scalar) return Boolean is <>; with function "-" ... ; with function "<" ... ; package Special_Math is ... end Special_Math; package Special_Int is new Special_Math(Scalar => Integer); package Special_Float is new Special_Math(Scalar => Float); -- Mark Biggar mark.a.biggar@home.com