From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: Sat, 30 Jan 1993 8:20:38 -0600 (CST) From: PETCHER@OTTAWA.dseg.ti.com (What? Me Ada?) Subject: Private type specifications Message-ID: <930130082038.2020028b@OTTAWA.DSEG.TI.COM> List-Id: > 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