comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ranges and discriminant constraints
Date: Sun, 08 Jun 2003 09:45:24 +0200
Date: 2003-06-08T09:45:24+02:00	[thread overview]
Message-ID: <bbupdk$crfca$1@ID-77047.news.dfncis.de> (raw)
In-Reply-To: 665e587a.0306072200.3d476477@posting.google.com

Vadim Godunko wrote:

> "AG" <ang@xtra.co.nz> wrote in message
> news:<b7tEa.15312$JA5.298948@news.xtra.co.nz>...
>> "Vadim Godunko" <vgodunko@vipmail.ru> wrote in message
>> news:665e587a.0306071258.1a8711cc@posting.google.com...
>> 
>> > Does anybody explain me why language allow constraint discriminant of
>> > discrete type to some value, but not allow constraint to range?
>> 
>> If I understood you correctly you mean something like this: [?]
>> 
>> type abc is (a, b, c);
>> type test(y: abc) is record
>>   ...
>> z: test(a);      -- Which compiles
>>   vs
>> z: test(a..c);  -- Which doesn't
>> 
> Not exactly. I mean:
> 
> type abc is (a, b, c);
> type r (k : abc) is record ...
> 
> subtype rab is r (a .. b);
> 
> procedure p (v : rab);

Maybe because the next requirement could be:

subtype rac is r (a | c);

However, if some time pre-/post-conditions would appear in Ada, one could 
have same effect with:

procedure p (v : r)
   when r.k = a or r.k = c; -- (ad-hoc subtype)

-- 
Regards,
Dmitry A. Kazakov
www.dmitry-kazakov.de



  reply	other threads:[~2003-06-08  7:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-07 20:58 Ranges and discriminant constraints Vadim Godunko
2003-06-07 21:51 ` AG
2003-06-08  6:00   ` Vadim Godunko
2003-06-08  7:45     ` Dmitry A. Kazakov [this message]
2003-06-08  2:22 ` David C. Hoos
2003-06-08  7:21   ` AG
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox