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 12:00:14 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!postnews1.google.com!not-for-mail From: mjsilva697@earthlink.net (Mike Silva) Newsgroups: comp.lang.ada Subject: Re: Localized Variable Declaration Date: 31 May 2002 12:00:13 -0700 Organization: http://groups.google.com/ Message-ID: <27085883.0205311100.4195811d@posting.google.com> References: <3CF77998.9040806@yahoo.com> <3CF77CDA.3090805@yahoo.com> <3CF78D3D.3030400@yahoo.com> NNTP-Posting-Host: 206.245.217.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1022871613 28826 127.0.0.1 (31 May 2002 19:00:13 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 31 May 2002 19:00:13 GMT Xref: archiver1.google.com comp.lang.ada:25113 Date: 2002-05-31T19:00:13+00:00 List-Id: David Rasmussen wrote in message news:<3CF78D3D.3030400@yahoo.com>... > So you can do the same in C++ as in Ada, and more. It's usually the > other way around. And usually Ada has a good reason for doing things > they way it does it. I just don't understand the justification for this > limitation. Consider this: > > void something() > { > cout << "Write two numbers: "; > int a; > cin >> a; > int b; > cin >> b; > double c = a * b * 42.42; > } Just as a matter of personal preference, I -hate- C++ code that has variables shuffled in with code this way! I find it extremely difficult to read. While I agree that forcing all variables to be declared in one place is unnecessarily limiting, I personally find it much more clear to declare -groups- of variables near where they will be used (by corresponding -groups- of program statements), rather than dropping them in one-by-one just before they are needed. I think the Ada way gives exactly the right fineness of conceptual granularity. Mike