home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ukma!bogus.sura.net!ra!mimsy!alex
- From: alex@cs.umd.edu (Alex Blakemore)
- Newsgroups: comp.lang.ada
- Subject: Re: private types and recompilation
- Message-ID: <63819@mimsy.umd.edu>
- Date: 28 Jan 93 23:44:26 GMT
- References: <7277@grus.cs.nps.navy.mil>
- Sender: news@mimsy.umd.edu
- Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
- Lines: 42
-
- erickson@taurus.cs.nps.navy.mil (David Erickson) writes:
- > 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
-
- The private part info is for use by the compiler which must know how much
- storage to reserve for objects of a private type based solely on
- information in the spec. Even if the program cannot know the
- representation details, the compiler must.
-
- So if you change the private part, you must recompile clients since
- that info has changed. But you are "guaranteed" that the compilation
- will succeed since the client cannot reference the implementation
- details.
-
- Rational allows you to change the private parts without invalidating
- clients if you use their subsystems.
-
- *** But there is a really nice trick that makes this much less of a
- problem. You can define a private type as an access type which
- designates an incomplete type to defer defining the representation to
- the package body. That gives the compiler enough info to allocate the
- proper amount of storage for objects of the private type. The only
- disadvantage to this is the extra time and complexity of using an
- access type.
-
- But you are already using access types anyway. So you can simply move
- the following lines to the package body and then any modifications to
- the type LIST do not force recompilations of the specification.
-
- > type LIST is record
- > A: ATOM;
- > NEXT: POSITION;
- > end record;
-
- You must leave these lines in the private part.
- type LIST;
- type POSITION is access LIST;
-
- --
- ---------------------------------------------------
- Alex Blakemore alex@cs.umd.edu NeXT mail accepted
-