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:7087:: with SMTP id f129mr7554877jac.38.1559587891895; Mon, 03 Jun 2019 11:51:31 -0700 (PDT) X-Received: by 2002:a9d:69c2:: with SMTP id v2mr2439905oto.22.1559587891714; Mon, 03 Jun 2019 11:51:31 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!i64no45837iti.0!news-out.google.com!l135ni33itc.0!nntp.google.com!4no45577itm.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 3 Jun 2019 11:51:31 -0700 (PDT) In-Reply-To: <12ffe476-35a7-4442-994e-9a03972619bc@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a02:c7d:3c35:b000:325a:3aff:fe0f:37a5; posting-account=L2-UcQkAAAAfd_BqbeNHs3XeM0jTXloS NNTP-Posting-Host: 2a02:c7d:3c35:b000:325a:3aff:fe0f:37a5 References: <28facad3-c55f-4ef2-8ef8-004925b7d1f1@googlegroups.com> <12ffe476-35a7-4442-994e-9a03972619bc@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <45206e16-8d5f-49fe-9978-b532eb5c1723@googlegroups.com> Subject: Re: Why .ads as well as .adb? From: Lucretia Injection-Date: Mon, 03 Jun 2019 18:51:31 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:56444 Date: 2019-06-03T11:51:31-07:00 List-Id: On Monday, 3 June 2019 14:37:46 UTC+1, John Perry wrote: > So I was surprised that some people made absolute negations of the possib= ility along these lines: >=20 > "You can't generate specification from implementation." I knew Wirth had done this already, but he missed the point. =20 > I especially wonder this since one of them had just referred to gnatchop,= whose online documentation provides an example that does precisely that [1= ]. So, when I read statements like the ones above, I wonder (a) if people u= nderstand that I don't mean Ada-as-is, but a hypothetically modified Ada (I= am not proposing such a modification Ada; again, it's just curiosity); and= (b) if I misunderstand what people mean by "specification". In Ada, I've written code which is organised like this: src/blah.ads src/blah.adb src/linux/blah-separate.adb src/windows/blah-separate.adb src/meh.ads src/linux/meh.adb src/windows/meh.adb etc. blah.ads is the interface to that package, it is what every OS sees, one in= terface, that's it. blah.adb is the body where it's portable. separate.adb = contains a "separate" which is a subprogram which is separated from the bla= h.adb because it's platform specific. In the gpr file, I enable the OS spec= ific directories. The meh package is similar except it has a whole body whi= ch is platform specific and therefore separated into the OS specific direct= ory. You can, if you want, create constants for the OS as well somewhere, i.e. Inside src/oses.ads: package OSes type OS is (Linux, Windows, etc.); end OSes; Inside src/linux/platforms.ads: -- Similar for Windows. with OSes; package Platforms OS : constant OSes.OS :=3D Linux; end Platforms; Then inside actual code: with Platforms; ... case Platforms.OS is when Platforms.Linux =3D> -- Linux code. when others =3D> -- Should be stripped from the final binary. end case; This method gives you compile time code stripping due to a static type syst= em and the constant OS, platform specific code in a directory and using stu= bs in platform specific directories. It's very powerful and a shitload less= messy than C and C++ methods of makefiles and preprocessor. Luke.