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=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,35782846f963b1e5 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.220.230 with SMTP id pz6mr18333084pbc.3.1341744757416; Sun, 08 Jul 2012 03:52:37 -0700 (PDT) Path: l9ni11132pbj.0!nntp.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: Manuel Collado Newsgroups: comp.lang.ada Subject: Re: on the need to duplicate code for procedure signature in both body and interface files Date: Sun, 08 Jul 2012 12:52:38 +0200 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: AQtcnCmK58GOCmVZT2XYxQ.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Date: 2012-07-08T12:52:38+02:00 List-Id: El 08/07/2012 1:08, Nasser M. Abbasi escribi�: > Basic question from an Ada newbie. > > One thing that always bothered me in Ada is the need > to physically duplicate the code that represents the API > of the package procedures and functions in both the interface > and the body files (.ads and .adb). > > I do not like duplicating code at all. Even if it is only > for the signature of the API, and even though the Ada > compiler will catch any difference (assuming one changes > the .ads and forget to update the .adb for example). It seems you are looking for a Java way of writing code. Java uses a single source file for each compilation unit. Signatures of public elements are implicitly assumed to be the interface part, while the remaining code gives the implementation. > > Was there no other alternatives to avoid this situation > when Ada was originally designed in order to keep the same > good concept of separating the interface from the body, but > somehow at the same time, eliminate the need to duplicate by > hand the API definition code in 2 separate places? As said in other responses, the obvious solution would be a specialized IDE that lets you edit a single combined spec+body source, and later split it on the fly into spec and body separate files for compilation. But such IDE seems not to exist yet. > > I am using GNAT. I Assume this is the same in other Ada > implementations. Yes. -- Manuel Collado - http://lml.ls.fi.upm.es/~mcollado