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

  1. Path: sparky!uunet!ukma!bogus.sura.net!howland.reston.ans.net!usc!news.service.uci.edu!ucivax!gateway
  2. From: kanderso@mabillon.ICS.UCI.EDU (Kenneth Anderson)
  3. Subject: Re: private types and recompilation
  4. Message-ID: <9301271722.aa25516@Paris.ics.uci.edu>
  5. Newsgroups: comp.lang.ada
  6. Lines: 47
  7. References: <7277@grus.cs.nps.navy.mil>
  8. Date: 28 Jan 93 01:22:24 GMT
  9.  
  10. In comp.lang.ada you write:
  11.  
  12. >When Ada 83 was designed, why did the designers choose to put
  13. >the details of private types in package specifications, rather than
  14. >in package bodies (which is more in the spirit of information hiding, and
  15. >better supports independent compilation).
  16.  
  17. I'm not sure, but I think because the compiler needs to know the size
  18. of the types so that it can allocate space for parameters in the
  19. subprograms that are defined in the spec.
  20.  
  21.  
  22. >generic
  23. >  type ATOM is private;
  24. >package LIST_ADT is
  25. >  type POSITION is private;
  26. >  type LIST is private;
  27. >  procedure CREATE(L: in out LIST);
  28. >  procedure INSERT_AFTER(L: in out LIST; P: POSITION; A: ATOM);
  29. >  ...
  30.  
  31. >private
  32. >  type LIST;
  33. >  type POSITION is access LIST;
  34.  
  35. You only need the previous two lines.  The declaration below can be
  36. hidden in the body of the package.
  37.  
  38. >  type LIST is record
  39. >    A: ATOM;
  40. >    NEXT: POSITION;
  41. >  end record;
  42. >end LIST_ADT;
  43.  
  44.  
  45. >-Dave Erickson
  46.  
  47. Ken
  48. --
  49. --------------------------------------------------------------------------------
  50. Ken Anderson                           |  "I'd much rather live in perfection,
  51. U.C. Irvine                            |   than deal with reality." -- Kenbod
  52. --------------------------------------------------------------------------------
  53. Happy! Happy! Happy! Joy! Joy! Joy!    |  Practice random kindness and
  54.                          -- Stimpy     |  senseless acts of beauty.
  55.                                        |  -- Anne Herbert
  56. --------------------------------------------------------------------------------
  57.