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!news3.google.com!newshub.sdsu.edu!newscon04.news.prodigy.net!prodigy.net!newsdst01.news.prodigy.net!prodigy.com!postmaster.news.prodigy.com!newssvr23.news.prodigy.net.POSTED!4988f22a!not-for-mail From: Newsgroups: comp.lang.ada 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> Subject: Re: Use of declare blocks X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original Message-ID: <%CIMh.1791$rj1.394@newssvr23.news.prodigy.net> NNTP-Posting-Host: 70.134.112.39 X-Complaints-To: abuse@prodigy.net X-Trace: newssvr23.news.prodigy.net 1174623803 ST000 70.134.112.39 (Fri, 23 Mar 2007 00:23:23 EDT) NNTP-Posting-Date: Fri, 23 Mar 2007 00:23:23 EDT Organization: AT&T http://yahoo.sbc.com X-UserInfo1: TSU[@SBEQJV]SQ@[EZOD]_\@VR]^@B@MCPWZKB]MPXHBTWICYFWUQBKZQLYJX\_ITFD_KFVLUN[DOM_A_NSYNWPFWNS[XV\I]PZ@BQ[@CDQDPCL^FKCBIPC@KLGEZEFNMDYMKHRL_YYYGDSSODXYN@[\BK[LVTWI@AXGQCOA_SAH@TPD^\AL\RLGRFWEARBM Date: Thu, 22 Mar 2007 21:23:46 -0800 Xref: g2news1.google.com comp.lang.ada:14602 Date: 2007-03-22T21:23:46-08:00 List-Id: "Randy Brukardt" wrote in message news:etveau$g29$1@jacob-sparre.dk... > > Anyway, I do understand the readability concerns, but I think they're > overblown. If you have to look 5 pages away to find a variable declaration, > the readability of the code it is used in isn't necessarily enhanced: you're > still flipping back and forth. Moreover, trying to come up with good names > for code that are made into subprograms just to keep the code "short" is > hard, and I know I'm not good at it. These supposed helpers are a real > headache during maintenance, because its rarely obvious what they do! How do > that help readability?? > Actually, you make my point for me. We certainly do not want to look all over the place for the name of a variable. On reason I like to use in-lined procedures instead of declare blocks is the ease of grouping like things together. Consider this contrived example: case X is when C1 => declare xxxxxx begin -- fifty lines of code end; when C2 => declare zzzzzzzz begin - twenty lines of code end; when ... end case; Even when we label the declare blocks, which I tend to do, this can get to be difficult to read and difficult to maintain. I might do this: procedure some_unit_name is procedure C1_Process is ... end C1_Process; pragma Inline (C1_Process); procedure C2_Process is ... end C2_Process; pragma Inline (C2_Process); -- more procedures as needed begin -- set up stuff case X is when C1 => C1_Process; when C2 => C2_Process; when ... end case; end some_unit_name; In the aerospace example, cited earlier, this is exactly how the code was rewritten to make it easier to read as well as easier to keep current. Originally, when I did not know better, we considered trying to make the nested procedures separate, but that did not work under the rules of Ada. I did hear that someone later worked this up into a package body and was able to do something using separate at the library level. I am not sure about that since I did not get to see the subsequent code. In your case, you and the small number of programmers who work with you are intimately familiar with the code. One of the benefits of Ada is that it makes it easier to manage turnover, reassignments, and all the other personnel movements that occur in a large software organization. I have seen declare blocks used in an ad hoc manner where the lack of documentation created difficulties for newcomers to a project. Giving something a specific, meaningful name can help, especially when it is the name of a procedure along with good names for the local variables used to make it work. I suppose we simply use the coding style most appropriate to the context in which we are working. As I noted, I am not opposed to declare blocks, but I am uncomfortable when large systems are designed so they rely heavily on them. Most organizations don't have the luxury of a stable workforce. Richard Riehle