From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,aea4cc77526f5e4a X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Separate Compilation in Programming Languages Date: Sat, 23 Feb 2008 10:16:56 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <7xJvj.7420$Ru4.4246@newssvr19.news.prodigy.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1203779817 20198 192.74.137.71 (23 Feb 2008 15:16:57 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 23 Feb 2008 15:16:57 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:FYR2fn07/IvYK9+gy461i1Ua8WY= Xref: g2news1.google.com comp.lang.ada:20026 Date: 2008-02-23T10:16:56-05:00 List-Id: writes: > My concern is dependency management. OK, but I still don't fully understand what you're getting at. You said elsewhere in this thread that you are NOT concerned with recompilation costs. That's good -- recompilation cost should primarily be an implementation concern. I'm guessing that your point has nothing to do with "compilation" at all, separate or otherwise. It has to do with the organization of the program into separate source files -- specifically separation of spec and body (interface and implementation, to use more language-neutral terms). Right? >...I will give an example in source > code. > > with X, Y, Z, Q, R, S; -- a set of library units on which we are dependent > package A is -- a package specification > > -- types and methods for this package > > end A; > > At this point, everything that is dependent on this specification is also > dependent on the library units on which A is dependent. In Ada, we > can move those dependencies to the package body. So, we have: > > package A is -- a package specification > > -- types and methods for this package > > end A; > > with X, Y, Z, Q, R, S; -- only body is dependent on these > package body A is -- a package specification > > -- implementation of package A > > end A; > > By moving the dependencies to the package body, the specification > is dependency free, as are all of the library units that become > dependent on it. OK, so you like having textually separate spec and body, as do I. But what specific advantages are you talking about in this thread? Readability? That is, when looking at a client of A, you don't need to worry about X,Y,...S. This is good, but it's got little to do with separate compilation. Source modification? A change in X could introduce a bug into a client of A -- so there really _is_ a dependency in that sense. One advantage of Ada over some languages (e.g. C) is that the implementation can know what source files are part of each program, by following the with clauses. I really hate having to write a make file that lists out all the .o files that need to be linked together -- Ada allows that to be completely automated (that's what gnatmake does). Something else? Note that Ada requires some implementation details to appear in the package spec -- namely, the stuff that goes in the private part, plus the with clauses needed by that private part. That's ugly, IMHO. >...Further, if we use the "is separate" feature, > we can push those dependencies even further down into the > implementation, not something any of the other languages > do very well. Shrug. I don't use "is separate" much. Child packages are almost always better, because you can separate the spec _and_ the body, and because the parent need not know about the child. Child packages provide the same advantage of being able to "push down" the dependencies. > I don't think this is possible in Java, Eiffel, or C#. It's possible using interfaces. Clients of an interface do not depend on classes that implement the interface, any more than clients of an Ada package spec depend on its body. You suggested otherwise elsewhere in this thread, but I think you're wrong, or else I'm misunderstanding what you mean by "depend". Interfaces are more flexible than spec/body in that they allow multiple "bodies". And of course Ada 2005 has interfaces. Note that an interface will typically be declared in a package spec with no corresponding body. >...It is only possible > in C++ by using the #include in the CPP file, and that is error-prone. I agree that #include is a kludge. > As noted by someone else, an automated configuration control > software can be of help in this regard, but it is not built into the > language as it is with Ada. >> > RD> By the way, Eiffel compilers typically use incremental compilation, > RD> which if implemented well, is strictly superior to separate > RD> compilation on a file-by-file basis. > > But it still does not seem to solve the dependency issue as cleanly as > Ada does. Eiffel has separate specs and bodies -- except that the spec is automatically generated from the body, rather than being written by hand. I prefer to consider the spec to be a source file in its own right, as in Ada, but it's not _that_ different from Eiffel. - Bob