comp.lang.ada
 help / color / mirror / Atom feed
* Some kind of repeating in Static_Predicate
@ 2018-06-03 17:45 ytomino
  2018-06-04  6:26 ` Jacob Sparre Andersen
  2018-06-06 11:04 ` Marius Amado-Alves
  0 siblings, 2 replies; 10+ messages in thread
From: ytomino @ 2018-06-03 17:45 UTC (permalink / raw)


Hello.

I'm trying to use a constant table (but that is unstable and may be changed in compile-time) in Static_Predicate.

 Set : constant String := ('T', 'a', 'b', 'l', 'e');
 
 subtype T is Character
    with Static_predicate => (for some I of Set => X = I);

Of cause, quantified expression in the static context is illegal.

 xx.ads:6:33: expression is not predicate-static (RM 3.2.4(16-22))

So, it have to be rewrote to

 subtype T is Character
    with Static_Predicate =>
       (T = Set (1)
          or else (Set'Last >= 2 and then T = Set (2))
          or else (Set'Last >= 3 and then T = Set (3))
          or else (Set'Last >= 4 and then T = Set (4))
          ...);

This looks stupid.
Is there any good alternative?

Thank you.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-06-07  9:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-03 17:45 Some kind of repeating in Static_Predicate ytomino
2018-06-04  6:26 ` Jacob Sparre Andersen
2018-06-04  7:15   ` ytomino
2018-06-04 21:33     ` Randy Brukardt
2018-06-05  2:30       ` ytomino
2018-06-05 20:37         ` Randy Brukardt
2018-06-04  7:17   ` ytomino
2018-06-06 11:04 ` Marius Amado-Alves
2018-06-06 14:53   ` ytomino
2018-06-07  9:15     ` Marius Amado-Alves

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