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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,583275b6950bf4e6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-30 02:21:54 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!enews.sgi.com!news.xtra.co.nz!53ab2750!not-for-mail From: "AG" Newsgroups: comp.lang.ada References: <3ECFF541.1010705@attbi.com> <3ED0B820.5050603@noplace.com> <3ED2096F.3020800@noplace.com> <3ED353BE.40605@noplace.com> <3ED4A323.3000909@noplace.com> <3ED5E8DE.8070308@noplace.com> Subject: Re: Saturated Math X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: Date: Fri, 30 May 2003 21:22:37 +1200 NNTP-Posting-Host: 219.88.60.240 X-Complaints-To: newsadmin@xtra.co.nz X-Trace: news.xtra.co.nz 1054286514 219.88.60.240 (Fri, 30 May 2003 21:21:54 NZST) NNTP-Posting-Date: Fri, 30 May 2003 21:21:54 NZST Organization: Xtra Xref: archiver1.google.com comp.lang.ada:38059 Date: 2003-05-30T21:22:37+12:00 List-Id: "Dale Stanbrough" wrote in message news:dstanbro-D4C3C0.18423630052003@mec2.bigpond.net.au... > I've just tried writing such a package (generic) and it doesn't seem > that it would be altogether seemless for the end user. > > Given a declaration like this... How about the following: [Just checked it on Gnat and it compiles fine] Declars: generic type number is range <>; package saturated is type saturated_number is new number; function "+"(left, right: saturated_number) return saturated_number; end; ---------------------------- Usage: ---------------------------- with saturated; procedure main is package saturated_int is new saturated(integer); use saturated_int; x: saturated_number := 4; begin x := x + 2; end; ---------------------------- > a calling procedure would look like this... > > procedure main is > type Number is new Integer range 1..5; > > package Saturated_Int is new Saturate (Number); > use Saturated_Int; > > x : Number := 4; > begin > x := Saturated_Int."+" (x, 2); > x := Saturated_Int."-" (x, 6); > end; > > > The function "+" in the following > > x := x + 2; > > is said to be ambiguous with Standard."+" (according > to gnat). In this case, the problem seems to be that the compiler (quite rightly) can't tell which "+" you mean since there are, in fact, two implementations visible at that spot. Regards .