comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: How to best make a custom range?
Date: Tue, 5 Nov 2019 07:10:43 -0800 (PST)
Date: 2019-11-05T07:10:43-08:00	[thread overview]
Message-ID: <d49d78cb-a8ae-4646-ab95-4c6d715ceb28@googlegroups.com> (raw)
In-Reply-To: <530a0f85-158a-4c42-b826-04ae4bd46451@googlegroups.com>

On Tuesday, November 5, 2019 at 7:02:37 AM UTC-7, Andrew Shvets wrote:
> This is what I have now.
> 
> subtype DNA_Chars is Character range ‘A’ .. ‘Z’;
> subtype DNA_Symbols is Character with Static_Predicate => DNA_Symbols in ‘ ‘;
> subtype DNA_Char is Character with Static_Predicate => DNA_Char in DNA_Chars | DNA_Symbols;
> 
> And this is the warning that I get (one of many, but I can’t copy and paste):
> 
> warning: in instantiation at a-nudira.adb:54
> type “Result_Subtype” has predicates, attribute “First” not allowed

OK, the problem here is that the Ada language *does* discriminate between subtypes with predicates and those without -- mostly because there are arguments about how such attributes should behave. Things like if we have:
   TYPE Digits is range 0..9;
   SUBTYPE Odds is Digits with Static_Predicate => Odds in 1|3|5|7|9;
what should Odds'Pred(1) be? 0? Constraint_Error?
what about Odds'Pos(1) should it be 0, the first item of the subtype? Or 1, the position in the parent-type?


  reply	other threads:[~2019-11-05 15:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-04 17:26 How to best make a custom range? Andrew Shvets
2019-11-04 17:56 ` Shark8
2019-11-04 18:49   ` Andrew Shvets
2019-11-04 19:16   ` Shark8
2019-11-05 14:02     ` Andrew Shvets
2019-11-05 15:10       ` Shark8 [this message]
2019-11-08 15:55         ` AdaMagica
2019-11-08 16:07           ` AdaMagica
2019-11-08 22:28           ` Randy Brukardt
2019-11-05 17:14       ` Dmitry A. Kazakov
2019-11-05 17:28         ` Shark8
2019-11-04 18:34 ` Dmitry A. Kazakov
2019-11-04 18:49   ` Andrew Shvets
2019-11-04 18:55     ` Dmitry A. Kazakov
2019-11-04 19:13       ` Shark8
2019-11-04 21:41         ` Dmitry A. Kazakov
replies disabled

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