comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: some questions re. Ada/GNAT from a C++/GCC user
Date: 1996/04/02
Date: 1996-04-02T00:00:00+00:00	[thread overview]
Message-ID: <Dp8w1s.I85@world.std.com> (raw)
In-Reply-To: 4jrhj0$lqd@tpd.dsccc.com

[Removed from comp.lang.c++, since I fear C++ folks are bored of this.]

In article <4jrhj0$lqd@tpd.dsccc.com>,
Kevin Cline <kcline@sun132.spd.dsccc.com> wrote:
>This is a flaw in the Ada language design, IMHO.  Why should
>different methods be used to externalize primitive and user-defined types?
>It certainly makes program maintainence more difficult; imagine a change
>from
>
>	type sequence_number_type is 0..2**32-1
>
>to
>
>	type sequence_number_type is 
>	record
>	  time: time_type;
>	  serial: 2**32-1;
>	end;
>
>If this change was not anticipated then every use of 'IMAGE to
>output a sequence number must be changed to IMAGE().

I suppose.  But you'll also have to change other stuff, like any numeric
literals, and any arrays indexed by sequence_number_type, and any
case_statements, which aren't legal when you change it to a record.
This is a much more general issue -- some prefer a language like Lisp,
which uses the same syntax for just about everything.

If Sequence_Number_Type is really an abstract data type, you'll probably
make it a private type in the first place, and then you won't have to
change anything outside the package.

Actually, I generally do *not* use Integer'Image directly -- I use a
function called Image, even for Integer types, and I use type derivation
to inherit it.  Partly for the reason you stated.  Also, Integer'Image
has an annoying habit of putting an extra unwanted blank, plus it
doesn't work for hexadecimal, and various other formatting options I
like to have.

>>The "&" operator just concatenates Strings.  So to
>>print out some stuff, you write:
>>
>>    Put("X = " & Integer'Image(X) & "; and List = " & Image(List));
>
>Sloshing all those characters around unnecessarily gets a bit
>expensive after a while.  This expression is likely to copy the list
>image twice before it is actually output.

True.  We were talking about debugging printouts, so it doesn't matter
in that context.  In a context where it *does* matter, you can call Put
once for each string.  Also, in Ada, you can define operators, so you
can play the same games as C++ does with "<<" and ">>", although you
have to use "&" or something as the operator name.  I've never done
that, because it seems ugly to me -- a matter of taste, I suppose.

- Bob




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

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-27  0:00 some questions re. Ada/GNAT from a C++/GCC user Bill Newman
1996-03-27  0:00 ` Robert Dewar
1996-03-28  0:00   ` Norman H. Cohen
1996-03-28  0:00   ` Brian Rogoff
1996-03-29  0:00     ` John G. Volan
1996-03-30  0:00       ` Robert A Duff
1996-03-31  0:00         ` John G. Volan
1996-03-31  0:00           ` Mike Young
1996-04-02  0:00             ` Glenn H. Porter
1996-04-02  0:00               ` Robert Dewar
1996-04-02  0:00               ` Jonas Nygren
1996-04-03  0:00               ` Geert Bosch
1996-04-03  0:00                 ` Robert Dewar
1996-04-01  0:00           ` Bruce.Conroy
1996-04-01  0:00           ` Robert A Duff
1996-04-03  0:00             ` Scott Leschke
1996-04-04  0:00               ` AdaWorks
1996-03-31  0:00         ` Robert Dewar
1996-04-01  0:00           ` Norman H. Cohen
1996-03-30  0:00       ` Mike Young
1996-03-30  0:00         ` Ted Dennison
1996-03-31  0:00           ` Mike Young
1996-04-01  0:00       ` Norman H. Cohen
1996-04-01  0:00         ` Mike Young
1996-04-02  0:00           ` David Shochat
1996-04-02  0:00             ` Mike Young
1996-04-02  0:00           ` Norman H. Cohen
1996-04-02  0:00           ` Robert Dewar
1996-04-01  0:00         ` Robert A Duff
1996-04-01  0:00           ` Mike Young
1996-04-02  0:00             ` Norman H. Cohen
1996-04-02  0:00             ` Robert A Duff
1996-03-28  0:00 ` Ted Dennison
1996-03-29  0:00   ` Adam Beneschan
1996-03-28  0:00 ` Scott Leschke
1996-03-29  0:00   ` Bill Newman
1996-03-29  0:00   ` Robert I. Eachus
1996-03-29  0:00   ` Robert A Duff
1996-03-30  0:00     ` Richard Pitre
1996-03-30  0:00       ` Robert A Duff
1996-03-31  0:00         ` AdaWorks
1996-04-01  0:00           ` Robert A Duff
1996-04-01  0:00             ` AdaWorks
1996-04-01  0:00               ` Mike Young
1996-04-02  0:00                 ` AdaWorks
1996-04-02  0:00                 ` Robert Dewar
1996-04-01  0:00             ` Norman H. Cohen
1996-04-01  0:00             ` Ken Garlington
1996-04-01  0:00               ` Robert A Duff
1996-04-02  0:00                 ` Tucker Taft
1996-04-02  0:00                   ` Felaco
1996-04-02  0:00                     ` Robert Dewar
1996-04-03  0:00                     ` Mark A Biggar
1996-04-02  0:00                 ` Ken Garlington
1996-04-02  0:00                   ` Robert A Duff
1996-04-02  0:00                     ` Ken Garlington
1996-04-02  0:00                       ` Robert A Duff
1996-04-03  0:00                         ` David Emery
1996-04-03  0:00                         ` Ken Garlington
1996-04-09  0:00                           ` Matt Kennel
1996-04-01  0:00         ` Robert Dewar
1996-04-01  0:00         ` Richard A. O'Keefe
1996-04-01  0:00           ` Robert A Duff
1996-04-02  0:00       ` Robert I. Eachus
1996-03-29  0:00 ` Robert A Duff
1996-03-29  0:00   ` Brian Rogoff
1996-04-01  0:00     ` Mark A Biggar
1996-04-01  0:00       ` Robert A Duff
1996-03-30  0:00   ` Iterators (was Re: some questions re. Ada/GNAT from a C++/GCC user) Robert I. Eachus
1996-03-31  0:00     ` Mike Young
1996-03-31  0:00       ` Fergus Henderson
     [not found]   ` <4jlj79$h1k@Nntp1.mcs.net>
1996-04-01  0:00     ` some questions re. Ada/GNAT from a C++/GCC user Robert A Duff
1996-04-02  0:00       ` Kevin Cline
1996-04-02  0:00         ` Robert A Duff [this message]
1996-04-01  0:00   ` Iterators (was Re: some questions re. Ada/GNAT from a C++/GCC user) Robert I. Eachus
1996-04-04  0:00   ` some questions re. Ada/GNAT from a C++/GCC user Jon S Anthony
1996-03-30  0:00 ` Simon Wright
1996-04-01  0:00 ` Laurent Guerby
1996-04-01  0:00   ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
1996-03-28  0:00 Simon Johnston
replies disabled

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