From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,543daa919438f82e X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: Access to aliased string declaration question. Date: 1999/06/10 Message-ID: #1/1 X-Deja-AN: 487836178 References: <375ED457.A85A462B@Boeing.com> NNTP-Posting-Date: Thu, 10 Jun 1999 01:52:11 PDT Newsgroups: comp.lang.ada Date: 1999-06-10T00:00:00+00:00 List-Id: On 10 Jun 1999 04:39, Matthew Heaney wrote: > It's not all that bad, either. Sometimes you can have it both ways by > declaring a dynamic (or maybe static) access subtype: > > type String_Access is access all String; > > S : aliased String (1 .. 10); > > ... > > declare > subtype S_Access is String_Access (S'Range); > SA : S_Access := S'Access; > begin > > Here we declare a subtype that points only to strings having the bounds > of object S. This is a constrained string object, designed by an access > object whose (base) type is unconstrained. Actually, you don't even need the subtype mark: declare SA : String_Access (S'Range) := S'Access; begin > This works even if the bounds are determined at run-time: > > procedure Op (F, L : Positive) is > > S : aliased String (F .. L); > > subtype S_Access is String_Access (F .. L); -- or S'Range > > SA : S_Access := S'Access; > > begin No subtype mark is needed here either: procedure Op (F, L : Positive) is S : aliased String (F .. L); SA : String_Access (S'Range) := S'Access; begin