comp.lang.ada
 help / color / mirror / Atom feed
From: alex@cs.umd.edu (Alex Blakemore)
Subject: Re: private types and recompilation
Date: 28 Jan 93 23:44:26 GMT	[thread overview]
Message-ID: <63819@mimsy.umd.edu> (raw)

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

             reply	other threads:[~1993-01-28 23:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-01-28 23:44 Alex Blakemore [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-01-28 18:08 private types and recompilation Mark A Biggar
1993-01-28 15:58 Pat Rogers
1993-01-28 15:25 Tucker Taft
1993-01-28 14:13 David Emery
1993-01-28  8:07 Christian S. Collberg
1993-01-28  1:22 Kenneth Anderson
1993-01-27 22:15 David Erickson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox