comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Subtype predicates
Date: Wed, 24 Aug 2016 09:45:51 -0700 (PDT)
Date: 2016-08-24T09:45:51-07:00	[thread overview]
Message-ID: <b007b97f-79a9-44da-beff-2a003831da4f@googlegroups.com> (raw)
In-Reply-To: <68b89d71-dd92-4b9c-adb9-476a7caa64cf@googlegroups.com>

On Wednesday, August 24, 2016 at 7:06:10 AM UTC-6, AdaMagica wrote:
> Am Dienstag, 23. August 2016 22:14:30 UTC+2 schrieb Anh Vo:
> > type Human_Life_Span_Type is range 0 .. 130 
> >   with Default_Value => Human_Life_Span_Type'First;
> 
> No, I think it's the rule that the name of the entity declared in a declaration (here Human_Life_Span_Type) may not be used again in the same declaration. (You cannot use something that is to be defined recursively in the definition.)
> 
> I just cannot find the RM chapter and verse.

I think it's different for aspects -- similar that Rosen's Trick the name of the declaration is referent to the instance of the type. So we could say something like:

   -- A string of upper-case letters followed by a single digit.
   Subtype ID_String is new String
   with Dynamic_Predicate => 
     (For all Index in ID_String'Range => 
       (if Index /= ID_String'Last
        then ID_String(Index) in 'A'..'Z'
        else ID_String(Index) in '0'..'9'
       )
     );


And since [some] aspects are essentially attribute-specification clauses (eg "Size => 8" = "For T'Size use 8;") there is some sense in thinking it is/should-be legit.


OTOH, you could certainly consider something like ID_String's predicate as being part of the definition.


  reply	other threads:[~2016-08-24 16:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-23 20:14 Subtype predicates Anh Vo
2016-08-24 13:06 ` AdaMagica
2016-08-24 16:45   ` Shark8 [this message]
2016-08-24 21:18     ` Anh Vo
2016-08-24 21:32       ` Shark8
2016-08-24 21:54   ` Jeffrey R. Carter
2016-08-25  0:08     ` Shark8
2016-08-25  0:31       ` Jeffrey R. Carter
2016-08-25 17:28         ` Anh Vo
2016-08-31 18:16       ` Randy Brukardt
2016-09-01  8:09         ` J-P. Rosen
2016-09-01 20:02           ` Randy Brukardt
2016-09-01 20:16         ` Shark8
replies disabled

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