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,bdd718faa7c79f29 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-28 23:23:32 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.mel.connect.com.au!news.xtra.co.nz!53ab2750!not-for-mail From: "AG" Newsgroups: comp.lang.ada References: <3EFE3491.F968568D@adaworks.com> Subject: Re: Overlapping ranges 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: Sun, 29 Jun 2003 18:24:38 +1200 NNTP-Posting-Host: 219.88.60.59 X-Complaints-To: newsadmin@xtra.co.nz X-Trace: news.xtra.co.nz 1056867810 219.88.60.59 (Sun, 29 Jun 2003 18:23:30 NZST) NNTP-Posting-Date: Sun, 29 Jun 2003 18:23:30 NZST Organization: Xtra Xref: archiver1.google.com comp.lang.ada:39879 Date: 2003-06-29T18:24:38+12:00 List-Id: "Richard Riehle" wrote in message news:3EFE3491.F968568D@adaworks.com... > AG wrote: > > > Assuming I have a package declaration like this: > > > > package range is > > type x1 is range 0..255; > > type x2 is range 127..2**15-1; > > end ranges; > > > > Is there a way to declare a function > > using that package that will accept > > values of either x1 or x2 (and nothing > > else) restricted to the range 127..255 ? > > Perhaps I don't understand why this is a problem for > you. Why not something such as, Because I don't want to allow an illegal value to make it inside the function (not even to raise an exception) What I was after was some implementation that won't need custom exceptions/error codes or so. > With this as a possible implementation of the body, > > package body ranges is > > function Fudge (A : X1; B : X2) return Number'Base is -- What happens here if you do something like -- X3 := A + 1 ??? > begin > if A in X1 then > return Number(A) + Number(B); > else > raise X1_Error; > end if; > end Fudge;