From: Shark8 <onewingedshark@gmail.com>
Subject: Re: How to best make a custom range?
Date: Mon, 4 Nov 2019 11:16:29 -0800 (PST)
Date: 2019-11-04T11:16:29-08:00 [thread overview]
Message-ID: <27cb5366-4b3d-4f33-b8ec-2bc71c70780c@googlegroups.com> (raw)
In-Reply-To: <21fa6db8-4b86-459f-bc5a-70993f92c28a@googlegroups.com>
On Monday, November 4, 2019 at 10:56:15 AM UTC-7, Shark8 wrote:
> On Monday, November 4, 2019 at 10:26:22 AM UTC-7, Andrew Shvets wrote:
> > Lets say I have the following code:
> >
> > subtype Test_Char is Character range ‘A’ .. ‘Z’;
> >
> > But what if I wanted to include ‘&’, ‘@‘ and ‘?’ in this custom range of characters as well? I thought of doing the following, but this obviously failed:
> >
> > subtype Test_Char is Character range ‘@‘ | ‘&’ | ‘?’ | ‘A’ .. ‘Z’;
> >
> > Or is this impossible unless I use a different approach?
>
>
> The approach I've been going with is splitting things apart into parts:
>
> Subtype Upper is Character range 'A'..'Z';
> Subtype Lower is Character range 'a'..'z';
> Subtype Symbol is Character
> with Static_Predicate => '&' | '@' | '?';
>
> Subtype Test_Character is Character
> with Static_Predicate => Upper | Lower | Symbol;
Ah, I forgot the SUBTYPE_NAME IN check, as well as the PREDICATE_FAILURE aspect.
Try:
Subtype Upper is Character range 'A'..'Z';
Subtype Lower is Character range 'a'..'z';
Subtype Symbol is Character
with Static_Predicate => Symbol in '&' | '@' | '?';
Subtype Test_Character is Character
with Static_Predicate => Test_Character in Upper | Lower | Symbol,
Predicate_Failure => Raise Constraint_Error;
next prev parent reply other threads:[~2019-11-04 19:16 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 [this message]
2019-11-05 14:02 ` Andrew Shvets
2019-11-05 15:10 ` Shark8
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