comp.lang.ada
 help / color / mirror / Atom feed
From: Laurent.Guerby@enst-bretagne.fr (Laurent Guerby)
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: <4xu3yzpoi7.fsf@leibniz.enst-bretagne.fr> (raw)
In-Reply-To: dewar.828631235@schonberg

Greg Bond writes
: Indeed it is. My oversight. This function does not handle the more 
: general problem I posed though. Is there a general facility for printing 
: access types? 

   No,  like in C you have  to convert them to  an integer type before
printing  them  using your  favourite  output routine   (printf or Put
;-).  This can be done in  "portable" Ada 95  (as far as  this kind of
game can be tagged as portable ...) :

   1. Instanciate System.Address_To_Access_Conversions for your object
   type, RM95-13.7.2.

   2. Use System.Storage_Elements.To_Integer to convert your Address
   to an implementation defined integer type, System.Storage_Elements. 
   Integer_Address, RM95-13.7.1.

   3. Use the Image attribute on this integer type. You can't use
   Text_IO.Integer_IO because the type can be a signed or modular integer
   type, RM95-13.7.1(13).

   4. Put (The_Resulting_String); --  !!

[Note: if you  want to do low  level manipulation, you've to cope with
chapter 13, and with 13.7 "The package System",  no other way, I think
most books, for many good reasons, don't talk about that.]

[Note 2 : I give  my vote for  chapter 13 as less human-comprehensible
part of the RM ;-]

[Note 3 : guess where you  find  the more  annotation in the annotated
reference manual ;-]

   Of course, if you're using GNAT (available  freely on most platform
used by  normal  human with  a keyboard  ;-), you can  safely use your
knowledge of the particular GNAT implementation ("Use the Source", see
my signature ;-).  And, as documented, all GNAT  basic types are the
same as their C equivalent ;-).

: The GNAT implementation of the Image function above is a 
: system level (i.e. platform dependent) routine specifically for the 
: Task_ID type. The only Ada references I've got are Barnes for Ada 95 and 
: the ALRM, both of which are woefully inadequate on the topic of Ada I/O.

   I don't share  your point of view  (both on Barnes  and on the RM95
;-).  You can do plenty  of things if  you take the  time to read  the
Text_IO  description in the RM (83  and 95), and  incredible things if
you take time to read the Stream section of the RM95 ;-).

-- 
--  Laurent Guerby, student at Telecom Bretagne (France), Team Ada
--  "Use the Source, Luke. The Source will be with you, always (GPL)"
--  http://www-eleves.enst-bretagne.fr/~guerby/ (GATO Project)
--  Try GNAT, the GNU Ada 95 compiler (ftp://cs.nyu.edu/pub/gnat)




  parent 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     ` Robert Dewar
1996-04-05  0:00     ` Keith Thompson
1996-04-05  0:00       ` Robert Dewar
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   ` Laurent Guerby [this message]
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