From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: How to best make a custom range?
Date: Tue, 5 Nov 2019 18:14:53 +0100
Date: 2019-11-05T18:14:53+01:00 [thread overview]
Message-ID: <qpsamd$1ohk$1@gioia.aioe.org> (raw)
In-Reply-To: 530a0f85-158a-4c42-b826-04ae4bd46451@googlegroups.com
On 2019-11-05 15:02, 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
Because ordering attributes are ones that get broken either way. Outside
generics the language threats them contravariant [the result is of the
base subtype], which breaks ordering but keeps much of other semantics.
When you pass a subtype as an actual parameter to a generic it suddenly
becomes covariant [the result of the subtype], which is sometimes worse,
sometimes quite impossible to implement. Ada plays safe here and just
does not let you. In other cases you might not be so lucky. The language
cannot deduce right semantics from the constraint. It is undecidable,
incomputable etc. In short, do not do that.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2019-11-05 17:14 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
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 [this message]
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