home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / ada / 4114 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.9 KB  |  52 lines

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!pipex!bnr.co.uk!bnrgate!nott!torn!spool.mu.edu!howland.reston.ans.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!news.sei.cmu.edu!ajpo.sei.cmu.edu!progers
  3. From: progers@ajpo.sei.cmu.edu (Pat Rogers)
  4. Subject: Re: private types and recompilation
  5. Message-ID: <1993Jan28.105829.5919@sei.cmu.edu>
  6. Sender: netnews@sei.cmu.edu (Netnews)
  7. Organization: Ada Joint Program Office
  8. References: <7277@grus.cs.nps.navy.mil> <9301271722.aa25516@Paris.ics.uci.edu>
  9. Date: Thu, 28 Jan 1993 10:58:29 EST
  10. Lines: 40
  11.  
  12. In article <9301271722.aa25516@Paris.ics.uci.edu> kanderso@mabillon.ICS.UCI.EDU (Kenneth Anderson) writes:
  13. >In comp.lang.ada you write:
  14. >
  15. >>When Ada 83 was designed, why did the designers choose to put
  16. >>the details of private types in package specifications, rather than
  17. >>in package bodies (which is more in the spirit of information hiding, and
  18. >>better supports independent compilation).
  19. >
  20. >I'm not sure, but I think because the compiler needs to know the size
  21. >of the types so that it can allocate space for parameters in the
  22. >subprograms that are defined in the spec.
  23. >
  24. >
  25.  
  26. Well, not really that, so much as that objects of the private type can be 
  27. allocated by users of the package before the package body is ever compiled.  
  28. So the compiler must have sufficient info from the package spec.  Incomplete
  29. type definitions might help you (sometimes called the "Deferred Implementation
  30. Scheme"):
  31.  
  32. package P is
  33.  
  34.   type Exported is private;
  35.   ...  operations on the type Exported ...
  36. private
  37.   type Implementation; -- incomplete type def
  38.   type Exported is access Implementation;
  39. end P;
  40.  
  41. package body P is
  42.   
  43.   type Implementation is ...
  44.  
  45. end P;
  46.  
  47. Note however that the language doesn't always force a recompilation, say,
  48. when a comment is added, or a private part is altered. It depends upon
  49. what was changed, but some implementations are "smart" about it.
  50.  
  51. Pat
  52.