home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!opl.com!hri.com!spool.mu.edu!uwm.edu!linac!unixhub!lll-winken!taurus!grus!erickson
- From: erickson@taurus.cs.nps.navy.mil (David Erickson)
- Newsgroups: comp.lang.ada
- Subject: private types and recompilation
- Message-ID: <7277@grus.cs.nps.navy.mil>
- Date: 27 Jan 93 22:15:35 GMT
- Organization: Naval Postgraduate School, Monterey
- Lines: 40
-
- When Ada 83 was designed, why did the designers choose to put
- the details of private types in package specifications, rather than
- in package bodies (which is more in the spirit of information hiding, and
- better supports independent compilation).
-
- As it stands now, if I write a program that withs a package that specifies
- private types, I must recompile that program if the details of the private
- types are modified, even if there is no change to the non-private
- specifications of the package.
-
- For example, if a linked list implementation is chosen, a LIST package
- might look like this:
-
- generic
- type ATOM is private;
- package LIST_ADT is
- type POSITION is private;
- type LIST is private;
- procedure CREATE(L: in out LIST);
- procedure INSERT_AFTER(L: in out LIST; P: POSITION; A: ATOM);
- ...
-
- private
- type LIST;
- type POSITION is access LIST;
- type LIST is record
- A: ATOM;
- NEXT: POSITION;
- end record;
- end LIST_ADT;
-
-
- but a program that uses the LIST package does not see the details of the
- private types, so why should a change in those details, say to an array
- implementation, cause the program to be recompiled.
-
- The problem could be avoided if the private portion of the package was
- moved to the package body or if it could be declared "is separate".
-
- -Dave Erickson
-