From: Richard Riehle <richard@adaworks.com>
Subject: Re: Overlapping ranges
Date: Sun, 29 Jun 2003 11:49:08 -0700
Date: 2003-06-29T18:46:06+00:00 [thread overview]
Message-ID: <3EFF34A4.AF0BB296@adaworks.com> (raw)
In-Reply-To: CBvLa.57412$JA5.1017777@news.xtra.co.nz
AG wrote:
> "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.
This is a good argument for the addition of pre-conditions,
post-conditions, and invariants to the language. I like the
designations from Eiffel. So the function might look like,
function Fudge(A, B : Number'Base) return Number'Base;
require A in X2'First..X1'Last; -- pre-condition
require B in X2'First..X1'Last; -- pre-condition
ensure return in X2'First..X2'Last; -- post-condition
The only problem now is what the program does with a pre-
or post-condition violation. The answer to this question is
not as trivial as it might at first seem.
Richard Riehle
prev parent reply other threads:[~2003-06-29 18:49 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
2003-06-29 6:42 ` AG
2003-06-29 18:40 ` Richard Riehle
2003-06-29 18:49 ` Richard Riehle [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox