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 10.107.163.5 with SMTP id m5mr12707724ioe.101.1517071247172; Sat, 27 Jan 2018 08:40:47 -0800 (PST) X-Received: by 10.157.90.130 with SMTP id w2mr1209685oth.14.1517071247023; Sat, 27 Jan 2018 08:40:47 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.unit0.net!peer02.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!w142no187493ita.0!news-out.google.com!s63ni235itb.0!nntp.google.com!g80no186169itg.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 27 Jan 2018 08:40:46 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:645:c001:2a91:c855:6eb4:1f88:d0f4; posting-account=fxr6CwoAAABjARAbZ01okNaxDpxQT8RH NNTP-Posting-Host: 2601:645:c001:2a91:c855:6eb4:1f88:d0f4 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <9dd4fa3e-4c0d-438d-9d6f-664a91347bfe@googlegroups.com> Subject: Re: Why *.adb and *.ads? From: Mace Ayres Injection-Date: Sat, 27 Jan 2018 16:40:47 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Body-CRC: 2753678640 X-Received-Bytes: 3458 Xref: reader02.eternal-september.org comp.lang.ada:50185 Date: 2018-01-27T08:40:46-08:00 List-Id: Ada, like Pascal, on which Ada is substantially based, requires declaratio= n of functions, procedures, and other elements (types I think) before they= are used, a pre-declaration. This is unlike other languages that allows yo= u declare and use and variable like Basic, or Python or the like where you = can invent things about anywhere on the fly. The Pascal/Ada =E2=80=9Cdefini= tion=E2=80=9D or pre declaration defines the type name, parameters in and r= eturn types, and supports the Strong Typing and safety characteristics of A= da. The compiler can then enforce proper use of the functions, procedures,= an types later in the program, because it has a reference standard, the pr= edeclaration/definition to validate proper use and compilation. In Pascal,= the declarations simply had to be put before the full body of the procedur= e/function, all in one file. With GNAT you can put the specification/predeclaration and body (full sourc= e code not just the high level definition) in a single file. But, by using the *.ads to contain the specification and the *.adb to conta= in the full elaboration, the pre-declaration/specification and subsequent b= ody distinction are enforced, both logically for the developer, and compile= r. Also, if you have a large body file *.adb, you can look at the *.ads and qu= ickly see all the functions and procedures that are in the body, though Ada= best practices says not to put loo many procedures and functions in a *.ad= b file (package). In the past, I have seen, and have myself, put a large co= mment section at the start of a body of code that listed all the following = procedures/functions, with parameters, and their intended use, in languages= that did not specifically require prior declarations.This useful in large = long lived programs where many developers may work on the code over time. I= t provides a quick way to see at a high level, what=E2=80=99s in a large bo= dy of code. Also, pre declaration/specification is a solid step forward in CS languages= when it emerged some decades past.