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,96daa6f775bc14b9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-03 03:32:24 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!195.54.122.107!newsfeed1.bredband.com!bredband!newsfeed1.telenordia.se!algonet!newsfeed1.funet.fi!newsfeeds.funet.fi!nntp.inet.fi!central.inet.fi!inet.fi!read2.inet.fi.POSTED!not-for-mail From: "Anders Wirzenius" Newsgroups: comp.lang.ada References: Subject: Re: Generics??? X-Newsreader: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Message-ID: Date: Tue, 03 Jul 2001 10:32:24 GMT NNTP-Posting-Host: 194.251.142.2 X-Trace: read2.inet.fi 994156344 194.251.142.2 (Tue, 03 Jul 2001 13:32:24 EET DST) NNTP-Posting-Date: Tue, 03 Jul 2001 13:32:24 EET DST Organization: Sonera corp Internet services Xref: archiver1.google.com comp.lang.ada:9364 Date: 2001-07-03T10:32:24+00:00 List-Id: Beard, Frank wrote in message ... >You can do it as a private, but you have to pass in the operations. >Attached is an example of what I'm talking about. Is this what >you're after? > >Frank > > >-----Original Message----- >From: Michael Andersson [mailto:a98mican@ida.his.se] > >Hi! >How do I specify that the generic parameter is a integer or a float. I >know that you can use >type T is range <> to specify that T is any Integer-type and that you >can use type T is digit <> to specify that T is any type of float. But >how can I use both at the same time? >I've tried to use type T is private but then I can't use any of the >+,-,*,/ operators. > >Need your help, please! >/Michael Andersson >_______________________________________________ >comp.lang.ada mailing list >comp.lang.ada@ada.eu.org >http://ada.eu.org/mailman/listinfo/comp.lang.ada > > May I join the thread with an additional question: Suppose I use the example provided by Frank Beard and want to round up the result when the type is an integer. How do I test which type the parameter (in the example: Item) is? Something like the pseudocode: function Divide (the_Left : Item; the_Right : Item) return Item is begin case Item is when integer => round up; when float => just divide ; when others => null; end case; return result of division; end Divide; Anders Wirzenius