comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Access to aliased string declaration question.
Date: 1999/06/10
Date: 1999-06-10T00:00:00+00:00	[thread overview]
Message-ID: <m3aeu8fn4t.fsf@mheaney.ni.net> (raw)
In-Reply-To: m3ogiofyua.fsf@mheaney.ni.net

On 10 Jun 1999 04:39, Matthew Heaney <matthew_heaney@acm.org> 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







  reply	other threads:[~1999-06-10  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-09  0:00 Access to aliased string declaration question Rex Reges
1999-06-10  0:00 ` Matthew Heaney
1999-06-10  0:00   ` Matthew Heaney [this message]
1999-06-10  0:00 ` Robert Dewar
replies disabled

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