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!aioe.org!.POSTED.3d73Ybk3C5U4I2t8lv+lAQ.user.gioia.aioe.org!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Why .ads as well as .adb? Date: Sun, 2 Jun 2019 08:39:23 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <28facad3-c55f-4ef2-8ef8-004925b7d1f1@googlegroups.com> NNTP-Posting-Host: 3d73Ybk3C5U4I2t8lv+lAQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:56433 Date: 2019-06-02T08:39:23+02:00 List-Id: On 2019-06-02 02:48, John Perry wrote: > I understand that Ada, like Modula-2 and Modula-3, and arguably like C++, requires a definition file (.ads) as well as an implementation file (.adb). With Oberon, Wirth moved away from definition files, using a symbol to indicate which module identifiers should be exported. (Someone else may have done this before him; it's just that I'm most familiar with this history.) Most languages I'm familiar with these days do something similar, either via public/private or some other mechanism. It is general design principle of separation specifications from implementations. Are you arguing against the principle or against keeping these things separately. The latter has evident advantages for code base maintenance, team development, testing, separate compilation etc. BTW, you can stuff bodies and specifications in the same file. It is purely compiler's business. See gnatchop for GNAT. So I consider it is the former you are against. > As far as I can tell, though, Ada has stuck with the two separate files, rather than, say, generating an .ads from an .adb with export markup. That is not possible. You cannot generate specification from implementation and conversely. In both cases there is additional information missing. It could be two different languages. Even in the languages that confuse these things, declarations have syntax different from definitions. Compare also Ada's declarative regions with C++'s ad-hoc declarations: declare X : Integer; begin ... -- Some code X := 1; end; { ... // Some code int X; X = 1; } > Is there a reason Ada hasn't moved to this simpler structure? See J-P's post. BTW when writing OS-dependent code it is very convenient to have one *.ads file and several *.adb files. It ensures that all client code is OS-independent, since it sees only the *.ads. And, in the tool-chain you just switch to another *.adb when changing the target. Compare that with C++'s #ifdef infestations. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de