From: "AG" <ang@xtra.co.nz>
Subject: Re: Overlapping ranges
Date: Sun, 29 Jun 2003 18:24:38 +1200
Date: 2003-06-29T18:24:38+12:00 [thread overview]
Message-ID: <CBvLa.57412$JA5.1017777@news.xtra.co.nz> (raw)
In-Reply-To: 3EFE3491.F968568D@adaworks.com
"Richard Riehle" <richard@adaworks.com> 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;
next prev parent reply other threads:[~2003-06-29 6:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-22 0:40 Overlapping ranges AG
2003-06-22 1:23 ` Mark A. Biggar
2003-06-22 2:58 ` AG
2003-06-22 3:17 ` tmoran
2003-06-22 17:55 ` Robert I. Eachus
2003-06-23 9:05 ` AG
2003-06-23 10:46 ` David C. Hoos
2003-06-24 8:09 ` AG
2003-06-29 0:36 ` Richard Riehle
2003-06-29 6:24 ` AG [this message]
2003-06-29 6:42 ` AG
2003-06-29 18:40 ` Richard Riehle
2003-06-29 18:49 ` Richard Riehle
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox