comp.lang.ada
 help / color / mirror / Atom feed
From: ytomino <aghia05@gmail.com>
Subject: Re: Some kind of repeating in Static_Predicate
Date: Mon, 4 Jun 2018 00:17:14 -0700 (PDT)
Date: 2018-06-04T00:17:14-07:00	[thread overview]
Message-ID: <a804d479-a245-4ae9-b94c-4440d272573d@googlegroups.com> (raw)
In-Reply-To: <87efhnoymp.fsf@jacob-sparre.dk>

On Monday, June 4, 2018 at 3:26:56 PM UTC+9, Jacob Sparre Andersen wrote:
> ytomino <agh...@gmail.com> writes:
> 
> > 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);
> 
> Why not admit that it is a Dynamic_Predicate?
> 
> Alternatively:
> 
>    type T is ('T', 'a', 'b', 'l', 'e');
> 
> Or:
> 
>    subtype T is Character
>       with Static_Predicate => (T in 'T' | 'a' | 'b' | 'l' | 'e');
> 
> Greetings,
> 
> Jacob
> -- 
> "people who live in glass houses shouldn't be throwing rocks
>  -- especially at those who don't live in glass houses"

Thanks. But I want to separate the table and the subtype...
As an example:

(A): a platform-depended private package

 private package Mylib.Platform_Depended is -- for POSIX
    Separators : constant String := ('/');
 end;

Or:

 private package Mylib.Platform_Depended is -- for Windows
    Separators : constant String := ('/', '\');
 end;

(B): using (A)

 private with Mylib.Platform_Depended;
 package Mylib.Path_Manipulators is
    Separators : constant String;
    subtype Directory_Separator is Character
       with Static_Predicate =>
          (for I of Separators => Directory_Separator = I); -- **error**
    function Compose (
       Path : String;
       Separator : Directory_Separator;
       Name : String) return String;
    ...
 private
    Separators : constant String := Platform_Depended.Separators;
 end;

The reason of it's not Dynamic_Predicate is, I wish compile-time warning if possible.

  parent reply	other threads:[~2018-06-04  7:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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