From: "James S. Rogers" <jimmaureenrogers@worldnet.att.net>
Subject: Re: Prefix to 'ACCESS must either statically match... But why?
Date: Mon, 27 Jan 2003 22:32:15 GMT
Date: 2003-01-27T22:32:15+00:00 [thread overview]
Message-ID: <PriZ9.6187$rq4.561874@bgtnsc05-news.ops.worldnet.att.net> (raw)
In-Reply-To: 5ad0dd8a.0301270746.6ad4c4b0@posting.google.com
If you want to use a more general access to string try using an access
to an unbounded string. See the following:
-- Array Access Test
with Ada.Text_Io;
with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
procedure Array_Access_Test is
type String_Access is access all String;
type Unbounded_Access is access all Unbounded_String;
procedure Print (
Item : in String_Access ) is
begin
Ada.Text_Io.Put_Line(Item.All);
end Print;
procedure Print(Item : in Unbounded_Access) is
begin
Ada.Text_Io.Put_Line(To_String(Item.All));
end Print;
Name : aliased String := "Jim Rogers";
Name2 : aliased Unbounded_String := To_Unbounded_String ("Jim Rogers");
Sa : String_Access;
Ua : Unbounded_Access;
begin
Sa := Name'access;
Print(Sa);
Ua := Name2'access;
Print(Ua);
end Array_Access_Test;
Passing around an access to an unbounded string has none of the limitations
you are finding with fixed strings. You do not create a new subtype for the
unbounded string type whenever you create an instance. The subtype is
always constant.
Jim Rogers
"Wojtek Narczynski" <wojtek@power.com.pl> wrote in message
news:5ad0dd8a.0301270746.6ad4c4b0@posting.google.com...
> Theoretically all clear, practically - major bummer.
>
> Looks like this used to work in some older version of GNAT:
>
> 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
>
> (From this thread:
> http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&frame=right
> &th=1de133c02ad2b2d3&seekm=m3ogiofyua.fsf%40mheaney.ni.net#link1)
>
> But now it doesn't with current (3.15p) GNAT nor current Aonix. Other
> variants I could think of don't work either.
>
> At present I can't come up with any idea on how to obtain a compatible
> access subtype.
>
> Regards,
> Wojtek
next prev parent reply other threads:[~2003-01-27 22:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-27 7:12 Prefix to 'ACCESS must either statically match... But why? Grein, Christoph
2003-01-27 15:46 ` Wojtek Narczynski
2003-01-27 22:32 ` James S. Rogers [this message]
2003-01-28 2:51 ` Wojtek Narczynski
2003-01-28 3:19 ` James S. Rogers
2003-01-28 12:14 ` Wojtek Narczynski
2003-01-28 14:43 ` James S. Rogers
2003-01-28 20:20 ` Wojtek Narczynski
2003-01-28 21:36 ` James S. Rogers
2003-01-29 2:09 ` tmoran
2003-01-29 11:21 ` Wojtek Narczynski
-- strict thread matches above, loose matches on Subject: below --
2003-01-30 6:20 Grein, Christoph
2003-01-29 12:15 Grein, Christoph
2003-01-29 11:57 Grein, Christoph
2003-01-29 6:50 Grein, Christoph
2003-01-29 11:30 ` Wojtek Narczynski
2003-01-27 6:41 Grein, Christoph
2003-01-27 18:33 ` Martin Krischik
2003-01-27 19:05 ` Jeffrey Carter
2003-01-25 22:31 Wojtek Narczynski
2003-01-26 9:57 ` Martin Krischik
2003-01-27 19:30 ` Vadim Godunko
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox