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=ham 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-7-bit Received: by 10.68.196.232 with SMTP id ip8mr21534686pbc.6.1341846685115; Mon, 09 Jul 2012 08:11:25 -0700 (PDT) Path: l9ni11215pbj.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: on the need to duplicate code for procedure signature in both body and interface files Date: Mon, 9 Jul 2012 08:11:24 -0700 (PDT) Organization: http://groups.google.com Message-ID: <97181340-e20e-4127-a1e8-f8c16088f4a5@googlegroups.com> References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1341846684 28819 127.0.0.1 (9 Jul 2012 15:11:24 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 9 Jul 2012 15:11:24 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-07-09T08:11:24-07:00 List-Id: On Saturday, July 7, 2012 4:08:53 PM UTC-7, Nasser M. Abbasi wrote: > Basic question from an Ada newbie. >=20 > 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). >=20 > 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). >=20 > 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? Overloading makes this an issue. But I think that having procedure and fun= ction declarations duplicated in the body is a big help for readability. I= f I'm looking at a procedure in the body, I can see what the declaration is= . In fact, one of the things I *don't* like about Ada is that when you wri= te a generic procedure or function, you can't duplicate the generic part in= the body. I really like having that information available when I read the= body, so that when I see a generic formal I know what it is without having= to flip back to the specification. Usually I just copy the generic formal= part into the body and comment it out. Anyway, I wrote a program a long time ago that takes text input with proced= ure and function declarations and provides empty bodies for them. So I jus= t copy and paste the spec part into the body and run it through the program= . -- Adam