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 12:55:04 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!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 15:33:37 -0400 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: <9n3aaj$l7c$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> <9n2l16$bqv$1@nh.pace.co.uk> <9n2pka$e44$1@nh.pace.co.uk> <3B951F33.927CA445@home.com> NNTP-Posting-Host: dhcp-200-133.miami.pace.co.uk X-Trace: nh.pace.co.uk 999632019 21740 136.170.200.133 (4 Sep 2001 19:33:39 GMT) X-Complaints-To: newsmaster@news.cam.pace.co.uk NNTP-Posting-Date: 4 Sep 2001 19:33:39 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:12717 Date: 2001-09-04T19:33:39+00:00 List-Id: You can get there via a variety of ways. One of my favorites is to declare an abstract tagged private type that has "+", "-", etc. as abstract functions. You can then use a generic formal that is of the 'Class of that tagged type. A user then derives from the abstract class and supplies the operations. That saves you from making a long generic formal list at the expense of making a long abstract function list. Don't know that there is a huge advantage to either one. But none of the possible solutions is as "clean" as simply having a "type X is scalar ;" generic formal parameter. (or some similar mechanism.) If Ada is smart enough to detect the operations for the actual parameter anyway, then maybe I don't have to do the work. That's always A Good Thing. 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/ "Mark Biggar" wrote in message news:3B951F33.927CA445@home.com... > > 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); >