comp.lang.ada
 help / color / mirror / Atom feed
From: wnewman@netcom.com (Bill Newman)
Subject: Re: some questions re. Ada/GNAT from a C++/GCC user
Date: 1996/03/29
Date: 1996-03-29T00:00:00+00:00	[thread overview]
Message-ID: <wnewmanDp18w0.L3@netcom.com> (raw)
In-Reply-To: leschkes.828053356@ferret

Scott Leschke (leschkes@ferret.cig.mot.com) wrote:
: wnewman@netcom.com (Bill Newman) writes:

: >When I make two different instantiations of a generic package with the
: >same arguments, I understand the compiler treats them formally as two
: >different packages, which is OK with me.  However, I'd appreciate
: >knowing the compiler wouldn't actually output two redundant copies of
: >the corresponding (identical?) machine code, but instead share the
: >code.  I saw somewhere that the compiler is given considerable freedom
: >to share one instantiation between several arguments if it thinks it's
: >appropriate, which is also OK with me.  However, I haven't seen any
: >guarantee that the compiler won't output redundant copies for
: >instantiations with identical arguments.  Is there such a guarantee?

: My first question would be, why do you want redundant instantiations.
: Note that Ada separates instantiation of a generic from use of the
: resulting package/subunit.  The general rule of thumb to avoid code-bloat
: due to duplicate instantiations is to do the instantiation at the library
: level and 'with' the resulting package/subunit.

I wondered about this because Ada encourages the creation of type
distinctions which don't reflect differences in underlying machine
representation.  In seems as though (mixing C++ template notation with
Ada's distinct types represented by machine floating point numbers)
Dynamically_Allocated_Stack_Of<Apple_Juice_Volume> and
Dynamically_Allocated_Stack_Of<Orange_Juice_Volume> could share
exactly the same underlying code.  It would be nice if the compiler
would recognize this without me having to figure out some way to
implement the templates/generics to make it explicit.  Even in C++
(without the option of conveniently making distinct Apples and Oranges
types out of e.g. float) this comes up frequently when you use
template containers of pointers to things: to the machine, a pointer
is a pointer, so the object code tends to be the same regardless of
the pointer type.  Sometimes in C++ I use a shared implementation for
such templates (using void* pointers, and the equivalent of Ada
Unchecked_Type_Conversion (?)) but even though the final result can be
type-safe if done correctly, it's tedious to make sure that it is, and
I'd rather not have to do it in Ada, especially since Ada strongly
discourages this sort of thing.  If the Ada type system multiplies the
number of cases where this would be useful, and if Ada discourages me
from doing it for myself, it would be nice if the Ada compiler would
do it for me.

  Bill Newman
  wnewman@netcom.com





  parent reply	other threads:[~1996-03-29  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           ` Robert A Duff
1996-04-03  0:00             ` Scott Leschke
1996-04-04  0:00               ` AdaWorks
1996-04-01  0:00           ` Bruce.Conroy
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           ` Robert Dewar
1996-04-02  0:00           ` Norman H. Cohen
1996-04-02  0:00           ` David Shochat
1996-04-02  0:00             ` Mike Young
1996-04-01  0:00         ` Robert A Duff
1996-04-01  0:00           ` Mike Young
1996-04-02  0:00             ` Robert A Duff
1996-04-02  0:00             ` Norman H. Cohen
1996-03-28  0:00 ` Scott Leschke
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             ` Ken Garlington
1996-04-01  0:00               ` Robert A Duff
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-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-01  0:00             ` Norman H. Cohen
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         ` Richard A. O'Keefe
1996-04-01  0:00           ` Robert A Duff
1996-04-01  0:00         ` Robert Dewar
1996-04-02  0:00       ` Robert I. Eachus
1996-03-29  0:00   ` Robert I. Eachus
1996-03-29  0:00   ` Bill Newman [this message]
1996-03-28  0:00 ` Ted Dennison
1996-03-29  0:00   ` Adam Beneschan
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
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