From: Robert A Duff <bobduff@TheWorld.com>
Subject: Re: Put the access value
Date: Mon, 20 Apr 2020 19:02:26 -0400
Date: 2020-04-20T19:02:26-04:00 [thread overview]
Message-ID: <wcck129hibh.fsf@shell02.theworld.com> (raw)
In-Reply-To: r73phu$58a$1@dont-email.me
"J-P. Rosen" <rosen@adalog.fr> writes:
> In Ada, a pointer is not an integer and has no 'Image attribute.
Sure it does. ;-)
So do records and everything else. See AI12-0020-1 (don't pay attention
to details; they're changing). I implemented that recently, so the
latest development version of GNAT has it.
This program:
with Ada.Strings.Text_Output.Formatting; use Ada.Strings.Text_Output;
procedure Access_Image is
type R is record
This : Integer;
That : String (1..10);
end record;
type A is access all R;
X : A := new R'(This => 123, That => "helloworld");
begin
Formatting.Put ("\1, \2\n", X'Image, X.all'Image);
end Access_Image;
prints:
(access 162b740),
(this => 123,
that => "helloworld")
> 1) Use Unchecked_Conversion to convert it to an appropriate integer type
>
> 2) use package Address_To_Access conversion to convert your pointer to
> an address, then System.Storage_Elements.To_Integer to convert the
> address to Integer_Address, which is an integer type.
Right, these are good workarounds if you don't have the latest
version.
- Bob
next prev parent reply other threads:[~2020-04-20 23:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-14 7:15 Put the access value ldries46
2020-04-14 7:42 ` J-P. Rosen
2020-04-18 15:08 ` Oliver Kellogg
2020-04-20 23:02 ` Robert A Duff [this message]
2020-04-21 7:07 ` briot.emmanuel
2020-04-21 22:29 ` Robert A Duff
2020-04-14 11:05 ` Jeffrey R. Carter
2020-04-14 12:09 ` ldries46
2020-04-15 7:20 ` briot.emmanuel
2020-04-15 8:02 ` AdaMagica
2020-04-15 8:51 ` J-P. Rosen
2020-04-15 16:23 ` AdaMagica
2020-04-17 14:20 ` Björn Lundin
2020-04-21 21:06 ` Randy Brukardt
2020-04-22 12:31 ` Björn Lundin
2020-04-22 17:33 ` AdaMagica
2020-04-23 11:37 ` Björn Lundin
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox