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,fc52c633190162e0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!l75g2000hse.googlegroups.com!not-for-mail From: "Adam Beneschan" Newsgroups: comp.lang.ada Subject: Re: Use of declare blocks Date: 21 Mar 2007 18:06:12 -0700 Organization: http://groups.google.com Message-ID: <1174525572.653359.103070@l75g2000hse.googlegroups.com> References: <1172144043.746296.44680@m58g2000cwm.googlegroups.com> <1172161751.573558.24140@h3g2000cwc.googlegroups.com> <546qkhF1tr7dtU1@mid.individual.net> <5ZULh.48$YL5.40@newssvr29.news.prodigy.net> <4eeMh.16400$bb1.2557@newssvr17.news.prodigy.net> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1174525574 19378 127.0.0.1 (22 Mar 2007 01:06:14 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 22 Mar 2007 01:06:14 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: l75g2000hse.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news1.google.com comp.lang.ada:14586 Date: 2007-03-21T18:06:12-07:00 List-Id: On Mar 21, 1:25 pm, "Randy Brukardt" wrote: > wrote in message > > news:4eeMh.16400$bb1.2557@newssvr17.news.prodigy.net... > ... > > >Units > > in Ada, including declare blocks (which ought to be used minimally) > > have the option of being named. > > While I generally agree with Richard, I certainly don't agree on the "ought > to be used minimally" here. > > I use declare blocks extensively to reduce the scope of temporary variables > in subprograms. They're especially important when the object exists just to > take an unused out parameter, because they greatly reduce the need to come > up with names for the objects. I often have code like: > > declare > Junk : Index; > begin > Insert_Something (..., Result => Junk); > end; > > where the result isn't needed by the following code. The thing I don't like about this is that it breaks up the algorithm. If you have a sequence of statements that implements some sort of algorithm, or a sequence of steps for getting what you want, I'd prefer to have all the statements together instead of being interrupted by lines with just keywords or declarations that I don't care about and that don't add to my understanding of the program. Having to skip over that stuff is harder on my eyes. But this is IMHO strictly a matter of personal preference and taste; there's certainly nothing wrong with your style and you have good reasons for it. -- Adam