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,86c750b8474bf6d5 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!198.186.194.249.MISMATCH!transit3.readnews.com!news-xxxfer.readnews.com!news-out.readnews.com!transit4.readnews.com!panix!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: About String Date: Sun, 15 Jun 2008 15:38:08 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <484ABED3.8040909@obry.net> <484b802a$0$23844$4f793bc4@news.tdc.fi> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1213558688 31309 192.74.137.71 (15 Jun 2008 19:38:08 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 15 Jun 2008 19:38:08 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:UEqh0tgqJog+UCEFjiffXbo5blI= Xref: g2news1.google.com comp.lang.ada:717 Date: 2008-06-15T15:38:08-04:00 List-Id: "Dmitry A. Kazakov" writes: > On Sun, 08 Jun 2008 17:19:11 -0400, Robert A Duff wrote: > >> Maciej Sobczak writes: >> >>> After all, with the possibility to initialize the new variable with >>> arbitrarily complex expression (including function call), this is >>> already the case and the whole declare-begin-end block is just >>> reflecting some artificial separation. >> >> I agree. I suppose it comes from Pascal, where declarations and >> executable code are completely separated. It makes no sense in >> Ada, where declarations are just as executable as statements. > > I disagree. I think it does make sense because it clearly defines the scope > of the declared variable. Expression (result) /= named object. And > reversely, if you don't need the variable, you are free to put expressions > anywhere outside the declaration part. If Ada allowed: for I in A'Range loop X : constant Character := F(A(I)); -- Not Ada! Do_Something(X); end loop; the scope of X is clear -- it's the entire loop body. for I in A'Range loop declare X : constant Character := F(A(I)); begin Do_Something(X); end; end loop; does not clarify (in my opinion). It just adds noise. You could still say: for I in A'Range loop begin X : constant Character := F(A(I)); -- Not Ada! Do_Something(X); end; Do_Something_Else; end loop; in my circus, if you want to further limit the scope of X (to smaller than the whole loop body). - Bob