comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: How to print Task_ID type? (GNAT SunOS)
Date: 1996/04/05
Date: 1996-04-05T00:00:00+00:00	[thread overview]
Message-ID: <dewar.828713391@schonberg> (raw)
In-Reply-To: DpE0yF.L65@thomsoft.com

Keith said

"Another possibility is something like this:

   declare
      P: Some_Access_Type := Some_Value;
      package SSE renames System.Storage_Elements;
   begin
      if P = null then
         Put_Line("P = null");
      else
         Put_Line("P = " & SSE.Integer_Address'Image
                              (SSE.To_Integer(P.all'Address)));
      end if;
   end;

Note, however, that the value stored in an access object isn't necessarily
the address of the designated object.  It could include or point to a
descriptor, among many other possibilities."

The method is fine, the test for null is appropriate (I missed that
in my message before!) The caution is probably unnecessary, I think
you will find that even in implementations where descriptors etc
are used, that 'Address is likely to point to the data. Remember
that X.all is the value of the type, and 'Address will normally
point to this data. You could make doubly sure in the only case
where there even conceivably could be trouble (arrays), by using

  x.all(x'first)'address

but at this stage, this is getting a bit junky, so even though it is
a bit more complexity, it is probably ceaner to instantiate 
address_to_access conversions to get the adress value.

I tink in GNAT we wlil make 'Img work for pointers, why not? Img is
designed to be helpful in debugging, and this would be helful 
eventually we would like 'Img to work for composite types as well).





  reply	other threads:[~1996-04-05  0:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-03  0:00 How to print Task_ID type? (GNAT SunOS) Greg Bond
1996-04-04  0:00 ` Robert Dewar
1996-04-04  0:00   ` Greg Bond
1996-04-04  0:00   ` Greg Bond
1996-04-05  0:00     ` Keith Thompson
1996-04-05  0:00       ` Robert Dewar [this message]
1996-04-06  0:00         ` Keith Thompson
1996-04-06  0:00           ` Robert Dewar
1996-04-07  0:00           ` Keith Thompson
1996-04-05  0:00       ` Greg Bond
1996-04-05  0:00     ` Robert Dewar
1996-04-05  0:00   ` Laurent Guerby
1996-04-04  0:00     ` Joel Sherrill
1996-04-06  0:00       ` Fergus Henderson
1996-04-06  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