home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / ada / 4116 < prev    next >
Encoding:
Internet Message Format  |  1993-01-29  |  1.6 KB

  1. Path: sparky!uunet!opl.com!hri.com!spool.mu.edu!uwm.edu!linac!unixhub!lll-winken!taurus!grus!erickson
  2. From: erickson@taurus.cs.nps.navy.mil (David Erickson)
  3. Newsgroups: comp.lang.ada
  4. Subject: private types and recompilation
  5. Message-ID: <7277@grus.cs.nps.navy.mil>
  6. Date: 27 Jan 93 22:15:35 GMT
  7. Organization: Naval Postgraduate School, Monterey
  8. Lines: 40
  9.  
  10. When Ada 83 was designed, why did the designers choose to put
  11. the details of private types in package specifications, rather than
  12. in package bodies (which is more in the spirit of information hiding, and
  13. better supports independent compilation).
  14.  
  15. As it stands now, if I write a program that withs a package that specifies
  16. private types, I must recompile that program if the details of the private 
  17. types are modified, even if there is no change to the non-private 
  18. specifications of the package.
  19.  
  20. For example, if a linked list implementation is chosen, a LIST package
  21. might look like this:
  22.  
  23. generic
  24.   type ATOM is private;
  25. package LIST_ADT is
  26.   type POSITION is private;
  27.   type LIST is private;
  28.   procedure CREATE(L: in out LIST);
  29.   procedure INSERT_AFTER(L: in out LIST; P: POSITION; A: ATOM);
  30.   ...
  31.  
  32. private
  33.   type LIST;
  34.   type POSITION is access LIST;
  35.   type LIST is record
  36.     A: ATOM;
  37.     NEXT: POSITION;
  38.   end record;
  39. end LIST_ADT;
  40.  
  41.  
  42. but a program that uses the LIST package does not see the details of the 
  43. private types, so why should a change in those details, say to an array
  44. implementation, cause the program to be recompiled.
  45.  
  46. The problem could be avoided if the private portion of the package was 
  47. moved to the package body or if it could be declared "is separate".
  48.  
  49. -Dave Erickson
  50.