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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a02:1986:: with SMTP id b128mr16661509jab.136.1559547348863; Mon, 03 Jun 2019 00:35:48 -0700 (PDT) X-Received: by 2002:a9d:3ee2:: with SMTP id b89mr173764otc.342.1559547348653; Mon, 03 Jun 2019 00:35:48 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!goblin1!goblin.stu.neva.ru!i64no1111933iti.0!news-out.google.com!l126ni23itl.0!nntp.google.com!4no1080376itm.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 3 Jun 2019 00:35:48 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=165.225.84.81; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S NNTP-Posting-Host: 165.225.84.81 References: <28facad3-c55f-4ef2-8ef8-004925b7d1f1@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Why .ads as well as .adb? From: Maciej Sobczak Injection-Date: Mon, 03 Jun 2019 07:35:48 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:56437 Date: 2019-06-03T00:35:48-07:00 List-Id: > That is not possible. You cannot generate specification from > implementation and conversely. Yes, you can. You can generate specs from implementations. > In both cases there is additional > information missing. Why is it missing? What if we put all information in implementation? Then there is nothing missing and we can generate specs from it. Your argument is not convincing. It can be expanded into: - I have separate spec and implementation files, so I can write my contracts in the spec and then I don't have to repeat them in bodies. - Well, I did not write my contracts in bodies, so they are not there and therefore something is missing, so I cannot generate specs from it. ? > 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; > } When I compare these two examples, I see that C++ is more readable, because it allows me to minimize the scope of names that are not needed until in later parts of code, without messing with useless constructs like this: begin -- some code declare X : Integer; begin X := 1; end; end; There is *nothing* gained in this construct and it is equivalent to the C++ example above. > BTW when writing OS-dependent code it is very convenient > to have one *.ads file and several *.adb files. I do that in C++, too. > And, in the > tool-chain you just switch to another *.adb when changing the target. And, in the tool-chain you just switch to another *.cpp when changing the target. > Compare that with C++'s #ifdef infestations. What? Why would anybody do that, apart from those few cases where this approach genuinely improves the readability of the code and where having separate compilation units would actually be more difficult to maintain? In other words: for multiplatform development, C++ gives me 2 solutions and I can choose the one which is more beneficial in the given context. Ada offers only one. How is this better? -- Maciej Sobczak * http://www.inspirel.com