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 X-Received: by 2002:a02:b78a:: with SMTP id f10mr4693295jam.5.1559469543837; Sun, 02 Jun 2019 02:59:03 -0700 (PDT) X-Received: by 2002:aca:d746:: with SMTP id o67mr4663056oig.157.1559469543577; Sun, 02 Jun 2019 02:59:03 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!85.12.16.68.MISMATCH!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!4no917209itm.0!news-out.google.com!e197ni109itc.0!nntp.google.com!4no917206itm.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 2 Jun 2019 02:59:03 -0700 (PDT) In-Reply-To: <28facad3-c55f-4ef2-8ef8-004925b7d1f1@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=188.150.24.77; posting-account=HFCrOQoAAABZD_f-UUbYHm3lJDIrh-UX NNTP-Posting-Host: 188.150.24.77 References: <28facad3-c55f-4ef2-8ef8-004925b7d1f1@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <30c51d4b-6248-49dc-8c87-eb3b98e12f5c@googlegroups.com> Subject: Re: Why .ads as well as .adb? From: joakimds@kth.se Injection-Date: Sun, 02 Jun 2019 09:59:03 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 3629 X-Received-Body-CRC: 1311222320 Xref: reader01.eternal-september.org comp.lang.ada:56434 Date: 2019-06-02T02:59:03-07:00 List-Id: Den s=C3=B6ndag 2 juni 2019 kl. 02:48:18 UTC+2 skrev John Perry: > Hello >=20 > 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 in= dicate 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 vi= a public/private or some other mechanism. >=20 > 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. >=20 > Is there a reason Ada hasn't moved to this simpler structure? >=20 > john perry Expanding on what Dmitry wrote it is not possible to generate specification= s from the implementation. Consider for example a simple function that take= s an integer as input and multiplies with 10 and then returns the result: function Multiply_By_10 (I : Integer) return Integer is begin return 10*I; end Multiply_By_10; One might think that the specification/declaration of this function is mere= ly function Multiply_By_10 (I : Integer) return Integer; but with contract-based programming it is possible to specify that the cont= ract for the integer argument must be a number between 1 and 10 and the res= ult must be a number between 10 and 100. function Multiply_By_10 (I : Integer) return Integer with Pre =3D> I >=3D 1 and I <=3D 10, Post =3D> Multiply_By_10'Result >=3D 10 and Multiply_By_10'Result <=3D 1= 00; The pre- and post-conditions may be important for static code analysis tool= s to prove/verify that an application is correctly implemented. Note that t= he information needed to specify the pre- and post-conditions are missing i= n the implementation. One could perhaps auto-generate pre- and post-conditi= ons from the body but it will probably not correspond to what the developer= wishes to set up as a contract for the subprogram. From my experience, the= specification of contracts can be many, many lines of code. To be able to = cleanly separate the contracts from the implementations is very useful and = convenient.