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!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!news.albasani.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Use of declare blocks Date: Wed, 21 Mar 2007 15:25:57 -0500 Organization: Jacob's private Usenet server Message-ID: 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: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1174508664 22803 69.95.181.76 (21 Mar 2007 20:24:24 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 21 Mar 2007 20:24:24 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Xref: g2news1.google.com comp.lang.ada:14578 Date: 2007-03-21T15:25:57-05:00 List-Id: 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. (Sure, one could argue that the underlying library should be improved to avoid the need for this, but that isn't always possible and in any case changes to widely used specifications shouldn't be made lightly. And this is just one example, any sort of temporary has these sorts of requirements.) The advantage is that if in the future you find that you no longer need the temporary, you can remove it without heavy code analysis: it is used only in the one place and there is no worries that it might be reused, or have a side-effect, or the like. Randy.