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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.unit0.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Why .ads as well as .adb? Date: Tue, 4 Jun 2019 00:04:06 +0300 Organization: Tidorum Ltd Message-ID: References: <28facad3-c55f-4ef2-8ef8-004925b7d1f1@googlegroups.com> <12ffe476-35a7-4442-994e-9a03972619bc@googlegroups.com> <2276685b-0e6b-46d1-ae7e-e7f1c0781dc0@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net arhGC1KVYryzNL45BoziFA8bR1LQyxvmPKFYwJeptM+sO9Aeb8 Cancel-Lock: sha1:XT7ptyJcnUgecVN+YtAvCS9Os4o= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: <2276685b-0e6b-46d1-ae7e-e7f1c0781dc0@googlegroups.com> Xref: reader01.eternal-september.org comp.lang.ada:56454 Date: 2019-06-04T00:04:06+03:00 List-Id: On 19-06-03 22:23 , John Perry wrote: > On Monday, June 3, 2019 at 9:50:03 AM UTC-5, Niklas Holsti wrote: >>> "teams can work separated from each other as needed, without the >>> project having to distribute all of the implementation to >>> everyone" >>> >>> [Having separate specification files against which one can >>> *compile* would be useful, not just convenient, though I think >>> it's arguable that one can do this in Oberon, too, via .smb >>> files and documentation.] >> >> If an Ada project needs to use an Ada library that is not >> open-source and was developed by someone else, the library >> provider can deliver the .ads source files to define the library >> API, but deliver only the object code for the .adb files, thus >> keeping the library implementation secret. Can Oberon .smb files do >> that? > > Yes; that's the entire point of an .smb file. The Oberon compilers > I'm familiar with generate both symbol (.smb) and object files (.o > or .class, depending on the target). I've tested that they will check > a module against .smb, without having an object file. Well and good! However (and as you said) the Oberon library must also be documented in some human-readable form (I assume the .smb files are not human-readable). In contrast the .ads files are human-readable (or at least programmer-readable). But perhaps Doxygen-type tools erase that difference between Ada and Oberon. (Personally I avoid Doxygen -- the source-code annotations feel ugly, decreasing both writability and readability. I much prefer tools that make code browsable and inter-linked without such annotations, for example gnathtml or an IDE like GPS, although these tools currently have some draw-backs in the source formatting they require.) > Wirth states in "Modula-2 and Oberon" [2] that symbol files have an > advantage over source files, in that the compiler can record a > version number with the file, and automatically update it. For GNAT, the compiler-generated .ali (Ada Library Information) files have timestamps etc. that serve that function, to check that the object files correspond to the .ads files. All Ada compilers are expected to check consistency of sources (as last compiled) and objects at bind/link-time, but I'm not sure if all compilers have the ability to do that when importing object code compiled by other parties into their program library. > ... so that made me > wonder why the .ads/.adb distinction was retained, at least in gnat. > (I'm not actually aware if that's required by the language itself.) The language requires that a package must have both a declaration and a body. These conform to different non-terminal symbols in the grammar and correspond to GNAT's .ads and .adb files. The language further requires the user to compile (or provide for compilation) the declaration before compiling the body, but the language does not require that the declaration text and the body text be in separate text files. In fact there is a non-terminal grammar symbol "compilation" that is a sequence of "compilation units", such as package declarations and bodies, and the standard says that an entire "compilation" can be submitted to the compiler. That's essentially why gnatchop was created. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .