comp.lang.ada
 help / color / mirror / Atom feed
From: ytomino <aghia05@gmail.com>
Subject: Some kind of repeating in Static_Predicate
Date: Sun, 3 Jun 2018 10:45:48 -0700 (PDT)
Date: 2018-06-03T10:45:48-07:00	[thread overview]
Message-ID: <4ece357c-025c-45ff-9f5d-89c89d47e6c0@googlegroups.com> (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.


             reply	other threads:[~2018-06-03 17:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-03 17:45 ytomino [this message]
2018-06-04  6:26 ` Some kind of repeating in Static_Predicate 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
replies disabled

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