Re: Separate Compilation in Programming Languages
- From: <adaworks@xxxxxxxxxxxxx>
- Date: Sat, 23 Feb 2008 23:31:58 -0800
"Robert A Duff" <bobduff@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:wccbq679zah.fsf@xxxxxxxxxxxxxxxxxxxxxxx
In the example you provided (shown below) you did defer the with clause
for the Package P1 to the package body of P2. This illustrates my point.
If the specification for P1 changes, only the body for P2 needs to be compiled.
Had the with clause been at the specification level for P2, and had the
specification for P1 changed, the entire package would have had to be
compiled.
I think the same is true for Java. If the specification for the Interface is
changed, everything needs to be recompiled. In Ada, by deferring the
with clause to the package body, we only need to re-compile the body.
So, I think your example actually supports my original assertion. The
essential point is that changes in the specifications for a package (or
a Java class) should not require re-compilation of the dependent
specifications. Only the implementations should be dependent on
other specifications. This has the effect of keeping the high-level
architecture more stable.
package P1 is
type Iface is interface;
... declare some abstract procedures ...
end P1;
package P2 is
pragma Elaborate_Body;
-- Note that this package spec can be entirely empty (except we
-- need the pragma so we are allowed to have a body).
-- So this package spec isn't defining any interface to
-- anything at all!
end P2;
with P1;
package body P2 is
type Impl is new P1.Iface with ...
... override procedures ...
...
end P2;
-- No body for P1!
Then the client can "with P1", and call operations on Iface objects
without knowing anything about package P2 (neither spec nor body).
There is no dependence of clients on P2 (unless I'm misunderstanding
what you mean by "depend").
.
- Follow-Ups:
- Re: Separate Compilation in Programming Languages
- From: Robert A Duff
- Re: Separate Compilation in Programming Languages
- References:
- Separate Compilation in Programming Languages
- From: adaworks
- Re: Separate Compilation in Programming Languages
- From: Robert A Duff
- Re: Separate Compilation in Programming Languages
- From: adaworks
- Re: Separate Compilation in Programming Languages
- From: Robert A Duff
- Re: Separate Compilation in Programming Languages
- From: adaworks
- Re: Separate Compilation in Programming Languages
- From: Robert A Duff
- Separate Compilation in Programming Languages
- Prev by Date: Re: Separate Compilation in Programming Languages
- Next by Date: Re: Separate Compilation in Programming Languages
- Previous by thread: Re: Separate Compilation in Programming Languages
- Next by thread: Re: Separate Compilation in Programming Languages
- Index(es):
Relevant Pages
|
|