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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,96ae138aab3beb03 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-31 11:33:52 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Localized Variable Declaration Date: 31 May 2002 14:30:04 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: <3CF77998.9040806@yahoo.com> <3CF77CDA.3090805@yahoo.com> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1022870250 1557 128.183.220.71 (31 May 2002 18:37:30 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 31 May 2002 18:37:30 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:25109 Date: 2002-05-31T18:37:30+00:00 List-Id: David Rasmussen writes: > > > > use 'declare' e.g. > > procedure Blah is > > begin -- Blah > > if Some_Function then > > declare > > Local_Variable : Integer; -- only visible within the block > > begin > > -- Do something with Local_Variable > > end; > > else > > end if; > > end Blah; > > > > Oh sure, but that is pretty tedious, compared to just a one line > variable declation. But the generated code is the same. Remember, Ada favors readability over writeability. In this case, the 'declare' makes it _very_ clear that you are starting a new block. That's _implied_ in C. > The point is, to be a bit extreme, that centralized variable > declations (e.g. at the "beginning" of the function) as done in C > and Pascal, are evil. Variables should be declared close to where > they are needed, IMO. Yep. That's what declare is for. Just because you don't like the answer, doesn't mean it isn't The Answer :). -- -- Stephe