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,1ce805592e46d231 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-04 06:45:04 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!news-x2.support.nl!news-x.support.nl!psinet-eu-nl!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: (elementary question) Test on type ? Date: Tue, 4 Sep 2001 09:30:13 -0400 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: <9n2l16$bqv$1@nh.pace.co.uk> References: <9n24g4$17q$1@snipp.uninett.no> <9n279a$1ua$1@snipp.uninett.no> <3B94B4B4.CE1955D6@nbi.dk> <9n2ctk$36v$1@snipp.uninett.no> NNTP-Posting-Host: dhcp-200-133.miami.pace.co.uk X-Trace: nh.pace.co.uk 999610214 12127 136.170.200.133 (4 Sep 2001 13:30:14 GMT) X-Complaints-To: newsmaster@news.cam.pace.co.uk NNTP-Posting-Date: 4 Sep 2001 13:30:14 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:12692 Date: 2001-09-04T13:30:14+00:00 List-Id: What you are trying to do is basically impossible in Ada. You can't have a generic parameter that is, say, "private" and then try to test to see if the actual is of type Integer or Float. There are a couple of reasons for this: One is that there are an infinite number of possible Integer types. You can declare your own integer types all day long, so how can you build into the code some sort of test to decide if the type is "Integer" and have that mean anything? Either it has to test for the *specific* type "Standard.Integer" in which case it misses all the other infinite number of possible integer types you can create, or it has to look for all things that exhibit the characteristics of integers. If the latter is the case, then you're down to: type X is range <> ; That way you know it can only be filled by an actual that satisfies the characteristics of integer types. But you want to also supply floating point types? Well, then you can't assume the characteristics of both integer types *and* floating point types because the sets of characteristics are different in many areas. (There is no Integer'Machine_Mantissa, for example) You have to go to the next level up and abstract away everything but the things that are common to both integer and floating point types. That would be a "private" formal type. You can't assume math ops or attributes because they are different between floating and discrete types - so you can only assume what is common to both. I think this illustrates a minor "hole" in the Ada language design. It would be nice to have a generic parameter that was somewhere between "private" and integer, decimal, float, etc. It would be nice to say: "type X is scalar ;" or similar and know that you can presume "+", "-", and other common math operations, but not necessarily those that make no sense for all mathematical types. Just a thought... 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/ "Reinert Korsnes" wrote in message news:9n2ctk$36v$1@snipp.uninett.no... > Jacob Sparre Andersen wrote: > > > Reinert: > > > >> > if X in Integer then > >> > >> I get error message "incompatible types"..... > > > > Then X is apparently not of type Integer. ;-) > > > > Seriously, what are you trying to do? > > Just do a bit different things in the function depending on the type > of X. Say, X is Float of Interger.... > > Maybe some dirty programming, but anyway. > > reinert > > > > > Jacob > > -- > http://home.chello.no/~rkorsnes