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

  1. Path: sparky!uunet!ukma!bogus.sura.net!ra!mimsy!alex
  2. From: alex@cs.umd.edu (Alex Blakemore)
  3. Newsgroups: comp.lang.ada
  4. Subject: Re: private types and recompilation
  5. Message-ID: <63819@mimsy.umd.edu>
  6. Date: 28 Jan 93 23:44:26 GMT
  7. References: <7277@grus.cs.nps.navy.mil>
  8. Sender: news@mimsy.umd.edu
  9. Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
  10. Lines: 42
  11.  
  12. erickson@taurus.cs.nps.navy.mil (David Erickson) writes:
  13. > When Ada 83 was designed, why did the designers choose to put
  14. > the details of private types in package specifications, rather than
  15. > in package bodies
  16.  
  17. The private part info is for use by the compiler which must know how much
  18. storage to reserve for objects of a private type based solely on
  19. information in the spec.  Even if the program cannot know the
  20. representation details, the compiler must.
  21.  
  22. So if you change the private part, you must recompile clients since
  23. that info has changed.  But you are "guaranteed" that the compilation
  24. will succeed since the client cannot reference the implementation
  25. details.
  26.  
  27. Rational allows you to change the private parts without invalidating
  28. clients if you use their subsystems.
  29.  
  30. *** But there is a really nice trick that makes this much less of a
  31. problem. You can define a private type as an access type which
  32. designates an incomplete type to defer defining the representation to
  33. the package body.  That gives the compiler enough info to allocate the
  34. proper amount of storage for objects of the private type.  The only
  35. disadvantage to this is the extra time and complexity of using an
  36. access type.
  37.  
  38. But you are already using access types anyway.  So you can simply move
  39. the following lines to the package body and then any modifications to
  40. the type LIST do not force recompilations of the specification.
  41.  
  42. >   type LIST is record
  43. >     A: ATOM;
  44. >     NEXT: POSITION;
  45. >   end record;
  46.  
  47. You must leave these lines in the private part.
  48.   type LIST;
  49.   type POSITION is access LIST;
  50.  
  51. -- 
  52. ---------------------------------------------------
  53. Alex Blakemore alex@cs.umd.edu   NeXT mail accepted
  54.