home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- 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
- From: progers@ajpo.sei.cmu.edu (Pat Rogers)
- Subject: Re: private types and recompilation
- Message-ID: <1993Jan28.105829.5919@sei.cmu.edu>
- Sender: netnews@sei.cmu.edu (Netnews)
- Organization: Ada Joint Program Office
- References: <7277@grus.cs.nps.navy.mil> <9301271722.aa25516@Paris.ics.uci.edu>
- Date: Thu, 28 Jan 1993 10:58:29 EST
- Lines: 40
-
- In article <9301271722.aa25516@Paris.ics.uci.edu> kanderso@mabillon.ICS.UCI.EDU (Kenneth Anderson) writes:
- >In comp.lang.ada you write:
- >
- >>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).
- >
- >I'm not sure, but I think because the compiler needs to know the size
- >of the types so that it can allocate space for parameters in the
- >subprograms that are defined in the spec.
- >
- >
-
- Well, not really that, so much as that objects of the private type can be
- allocated by users of the package before the package body is ever compiled.
- So the compiler must have sufficient info from the package spec. Incomplete
- type definitions might help you (sometimes called the "Deferred Implementation
- Scheme"):
-
- package P is
-
- type Exported is private;
- ... operations on the type Exported ...
- private
- type Implementation; -- incomplete type def
- type Exported is access Implementation;
- end P;
-
- package body P is
-
- type Implementation is ...
-
- end P;
-
- Note however that the language doesn't always force a recompilation, say,
- when a comment is added, or a private part is altered. It depends upon
- what was changed, but some implementations are "smart" about it.
-
- Pat
-