Re: Separate Compilation in Programming Languages




"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").


.



Relevant Pages

  • Re: Clause "with and use"
    ... Dispatching would be a joke if you *always* had to ... something "good" about the "use" clause. ... The display operations belong in the package ...
    (comp.lang.ada)
  • Re: Fatal Error about a package that I cannot find.
    ... does the software product that you created launch ... check your uses clause and remove any components listed in there ... I re-installed Delphi ... There is no package called tee anywhere that I can ...
    (alt.comp.lang.borland-delphi)
  • Re: BA:Free £20 voucher for dvd.co.uk
    ... whilst reading the small print so make sure you don't get caught out with ... Or did i have to sign up for a more premium ... No, I only signed up for the £9.99 package as well, no need to sign up for a ...
    (uk.media.dvd)
  • Re: Clause "with and use"
    ... The display operations belong in the package ... :> operations instantiate that package. ... Now the use clause is for a local ...
    (comp.lang.ada)
  • Re: Clause "with and use"
    ... >clause has an effect on visibility that includes the use clause. ... >1) The new rule you are proposing makes lots of existing legal Ada ... However I would not call it another set of resolution rules. ... package B is ... ...
    (comp.lang.ada)