comp.lang.ada
 help / color / mirror / Atom feed
* Private type specifications
@ 1993-01-30 14:20 What? Me Ada?
  0 siblings, 0 replies; only message in thread
From: What? Me Ada? @ 1993-01-30 14:20 UTC (permalink / raw)


> From: willson@seas.gwu.edu (Stephen R. Willson)

> I am not sure I understand the purpose of placing a type specification in
> the body of a package, as a way to "hide" the specification from the
> "client".  Does someone have an example of where someone would want to
> hide the type in such a way?

Without having extensive experience in Ada programming but having followed it
for a lot of years and having plenty of experience with nuisances in other
languages, I can think of a couple of reasons.  One is simply that there's no
need to clutter a compiler's symbol table with information it is not expected
to need.  Another reason, probably more important, is that needlessly
exported type specifications might clash with external use of the same name
for something else.  When a package has private data of a type that is only
used internally it makes sense to make the type specification as well as the
data object itself private.  On the other hand, if a package maintains
private data but provides copies of it to clients, then the data needs to be
private but the type specification needs to be public.  Contrast this with C
where the closest thing to a package spec is a header file that includes
function prototypes and type definitions.  Any client who needs the
prototypes gets the typedefs as well.  Not that it has to be done that way,
but it usually is because that's the easiest way.  To do it right in C takes
two or even three header files so as to separate client and server
information.  Ada makes it somewhat easier.

In this vein, and hoping not to start another language war, I'll point out
that having only recently started doing hands-on work with Ada, I'm finding
that if I want to go off and write some small to medium utility by myself I
still prefer C.  However, when I need to understand or modify somebody else's
code, I find Ada clearly superior.  On the last multi-person C project I was
on it was standard practice to have printouts of a half dozen frequently used
header files taped to the wall near each workstation.  Working with Ada I
typically find all I need is a printout (or virtual screen) of the spec for
the package I'm using in a client.

Malcolm Petcher
Petcher@ottawa.dseg.ti.com

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1993-01-30 14:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-01-30 14:20 Private type specifications What? Me Ada?

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