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 06:32:19 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newspeer.clara.net!news.clara.net!peernews!peer.cwci.net!newspeer1-gui.server.ntli.net!ntli.net!news8-gui.server.ntli.net.POSTED!53ab2750!not-for-mail From: "martin.m.dowie" Newsgroups: comp.lang.ada References: <3CF77998.9040806@yahoo.com> Subject: Re: Localized Variable Declaration X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Fri, 31 May 2002 14:32:10 +0100 NNTP-Posting-Host: 62.252.150.84 X-Complaints-To: abuse@ntlworld.com X-Trace: news8-gui.server.ntli.net 1022851938 62.252.150.84 (Fri, 31 May 2002 14:32:18 BST) NNTP-Posting-Date: Fri, 31 May 2002 14:32:18 BST Organization: ntlworld News Service Xref: archiver1.google.com comp.lang.ada:25075 Date: 2002-05-31T14:32:10+01:00 List-Id: "David Rasmussen" wrote in message news:3CF77998.9040806@yahoo.com... > I am a C++ programmer learning Ada. So far, I love it. It is more or > less the answer to my prayers. The only thing I miss which I think > really enhances readability and minimizes bugs (two things that Ada > excels at), is the ability to declare a variable "anywhere". In C++ we > can declare a variable exactly when it is needed, which is easier to > read, than to have to scroll up to the beginning of the function to see > what type/size/whatever, a variable is. Also, it directly makes it > possible more often to initialize a variable with a sensible value, > because it is available, which it wouldn't be at the start of the > function/scope. > > Is there anyway to address this problem? 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;