comp.lang.ada
 help / color / mirror / Atom feed
From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!think.com!spool.mu.edu!agate !dog.ee.lbl.gov!hellgate.utah.edu!cs.utah.edu!kmsimons@ucbvax.Berkeley.EDU  (Ke vin Simonson)
Subject: integer'image versus integer_io
Date: 13 Apr 92 17:31:49 GMT	[thread overview]
Message-ID: <1992Apr13.113149.20126@hellgate.utah.edu> (raw)

     If I want to output an integer to standard output, or to a file, I can
do it either by instantiating the generic package "integer_io", or by using
the "integer'image" attribute.  Therefore the following code gives me iden-
tical results:

   package IIO is new text_io.integer_io (integer);
   II : integer;

   text_io.put ("Enter value:  ");
   IIO.get (II);
   text_io.put ("Value entered is [");
   IIO.put (II, 1);
   text_io.put_line ("].");

                         versus

   package IIO is new text_io.integer_io (integer);
   II : integer;

   text_io.put ("Enter value:  ");
   IIO.get (II);
   text_io.put_line ("Value entered is [" & integer'image (II) & "].");

     The only difference I get from my compiler is that with the "'image"
version there's an extra space in front of the integer for a sign value.

     My question is, if you want to output integers mixed with text, and if
you don't mind about that first position for the sign, is there really any
reason to use an "integer_io" instantiation over just using
"integer'image"?

     It seems like the "'image" version would be more effective, too, since
in the other version I'd have to use three I/O calls, versus the one I/O
call for the concatentated string.

     If anybody knows any reason why concatenating "integer'image" might
cause me any grief, please let me know.  Respond by e-mail if you can; it
takes forever for these articles to get to my network.  Thanks.

                                     ---Kevin Simonson

             reply	other threads:[~1992-04-13 17:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-04-13 17:31 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!think.com!spool.mu.edu!agate [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-04-15 17:56 integer'image versus integer_io Pete Carah
replies disabled

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