From: Matt Borchers <mattborchers@gmail.com>
Subject: Re: array from static predicate on enumerated type
Date: Thu, 18 Mar 2021 17:10:31 -0700 (PDT) [thread overview]
Message-ID: <c042f9a6-1c1c-4dc6-9668-2ef84c0e8397n@googlegroups.com> (raw)
In-Reply-To: <s2v2ff$aht$1@gioia.aioe.org>
Dmitry,
I don't think we can blatantly say that subtypes are types in every sense of the meaning. If they were distinct then there would be no difference between:
subtype HEX_LETTERS is LETTERS range A..F;
and
type HEX_LETTERS is new LETTERS range A..F;
when given:
type LETTERS is ( A, B, C, D, E, F, G, H, I, J, K );
Please correct me if I am wrong, but I have always thought that the values A through F in the sub-type were the same values of the parent type and are effectively used interchangeably with the corresponding values of the parent type. The sub-type simply provides a kind of restricted "view" constraint. That is, the constraint checking used for variables of these types depends on the type "view" of the variable. I don't know if I can explain myself very well. I expected, therefore, that when a Static_Predicate was applied to the sub-type, just a more complex constraint checking routine would be applied rather that a simple "in range" check.
>> I think you misunderstood me. Given the following,
>> function L_POS( x : LETTERS ) return NATURAL is (LETTERS'Pos(x));
>> and
>> function CL_POS( x : CURVED_LETTERS ) return NATURAL is (CURVED_LETTERS'Pos(x));
>>
>> I would have expected the following results:
>> 1 <= l_pos(B)
>> 0 <= cl_pos(B)
>> 4 <= l_pos(E)
>> exception <= cl_pos(E)
> That would be a total catastrophe.
In regards to what L_POS and CL_POS return, I don't understand why that would be a catastrophe. Those values seem like reasonable answers to what the programmer requested. This is really the point of this pose and my question in the first place: What is the reason that there is absolutely no way to implement useful results for 'First, 'Last, etc. with Static_Predicates? And because of this, what is the best work-around? And I do feel like this requires a work-around.
If CURVED_LETTERS with a predicate is not a sub-type, then it should not be declared with a sub-type keyword. I like the word you used: subset. It should have been:
subset CURVED_LETTERS is LETTERS (B,C,D,G,J);
And then Ada can be free to define a whole new set of rules for sub-sets while keeping sub-types consistent.
Regards,
Matt
next prev parent reply other threads:[~2021-03-19 0:10 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-12 20:49 array from static predicate on enumerated type Matt Borchers
2021-03-12 21:22 ` Egil H H
2021-03-12 22:16 ` Jeffrey R. Carter
2021-03-12 22:41 ` Dmitry A. Kazakov
2021-03-13 2:06 ` Matt Borchers
2021-03-13 4:55 ` Randy Brukardt
2021-03-15 14:16 ` Matt Borchers
2021-03-15 17:53 ` Shark8
2021-03-16 6:58 ` Randy Brukardt
2021-03-13 8:04 ` Dmitry A. Kazakov
2021-03-15 14:11 ` Matt Borchers
2021-03-15 17:48 ` Shark8
2021-03-15 20:25 ` Dmitry A. Kazakov
2021-03-16 13:27 ` Shark8
2021-03-16 14:25 ` Dmitry A. Kazakov
2021-03-17 4:05 ` Matt Borchers
2021-03-17 7:08 ` Dmitry A. Kazakov
2021-03-17 18:44 ` Matt Borchers
2021-03-17 19:41 ` Dmitry A. Kazakov
2021-03-18 1:30 ` Matt Borchers
2021-03-18 8:20 ` Dmitry A. Kazakov
2021-03-19 0:10 ` Matt Borchers [this message]
2021-03-19 8:00 ` Dmitry A. Kazakov
2021-03-18 10:15 ` Niklas Holsti
2021-03-18 10:47 ` AdaMagica
2021-03-18 11:26 ` Dmitry A. Kazakov
2021-03-19 0:34 ` Matt Borchers
2021-03-19 0:49 ` Jeffrey R. Carter
2021-03-23 1:07 ` Matt Borchers
2021-03-23 3:43 ` Randy Brukardt
2021-03-22 19:09 ` Niklas Holsti
2021-03-17 15:08 ` Shark8
2021-03-17 19:08 ` Matt Borchers
2021-03-17 20:41 ` Shark8
2021-03-18 1:04 ` Matt Borchers
2021-03-18 14:25 ` Shark8
2021-03-18 23:36 ` Matt Borchers
2022-03-16 0:38 ` Thomas
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox