From: tmoran@acm.org
Subject: Re: Overlapping ranges
Date: Sun, 22 Jun 2003 03:17:39 GMT
Date: 2003-06-22T03:17:39+00:00 [thread overview]
Message-ID: <md9Ja.1014616$OV.1113610@rwcrnsc54> (raw)
In-Reply-To: 5W8Ja.43776$JA5.768297@news.xtra.co.nz
> Exactly. And that's the problem - I'm looking for a way
> to declare a function [and/or whatever] that could handle
> values of either of the two [test-bed of course] types and,
> on top of that, impose range restrictions on the values passed in.
Can you just have two different functions overloading a single name?
type x1 is range 0..255;
type x2 is range 127..2**15-1;
subtype x1_and_x2_range is x1 range 127 .. 255;
subtype x2_and_x1_range is x2 range 127 .. 255;
function f(x : x1_and_x2_range) return ...
function f(x : x2_and_x1_range) return ...
an_x1 : x1;
an_x2 : x2;
...
result := f(an_x1); -- checks an_x1 in 127 .. 255, then calls first "f"
result := f(an_x2); -- checks an_x2 in 127 .. 255, then calls second "f"
next prev parent reply other threads:[~2003-06-22 3:17 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 [this message]
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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox