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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5117b1b6391a0e06 X-Google-Attributes: gid103376,public Path: g2news1.google.com!news1.google.com!news.glorb.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!gnilink.net!nwrdny01.gnilink.net.POSTED!0e8a908a!not-for-mail From: Hyman Rosen User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: A simple ADA puzzle (I haven't the answer) References: <1087410710.477506@master.nyc.kbcfp.com> <1087474761.60413@master.nyc.kbcfp.com> <7o83d0hf6sqgng2980e1tg7iu864m5m50u@4ax.com> <1in5d05aa4rfqlt7e76gk87ucd3vuru6pm@4ax.com> <1087564576.388973@master.nyc.kbcfp.com> <1087575262.304708@master.nyc.kbcfp.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Mon, 21 Jun 2004 03:30:32 GMT NNTP-Posting-Host: 68.161.72.156 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny01.gnilink.net 1087788632 68.161.72.156 (Sun, 20 Jun 2004 23:30:32 EDT) NNTP-Posting-Date: Sun, 20 Jun 2004 23:30:32 EDT Xref: g2news1.google.com comp.lang.ada:1720 Date: 2004-06-21T03:30:32+00:00 List-Id: Dmitry A. Kazakov wrote: > What's the gain of limiting scope here? A relief for lazy > programmers, who do not want to create extra *.h files? The same gain as any limitation of scope - localizing things to the narrowest region where they are needed. It is no less sensible than Ada's declare statement. I often write tiny classes whose job is nothing more than invoking a cleanup function on an object in its destructor. I put them right next to the object they will be handling. > Limiting scope is useful, but it should be made consistently. > Clearly a nested thing should see everything from its scope. C and C++ do not choose to allow closures because of difficulties with function pointers that result. So it is clear that access to local variables will never be permitted. The question is then whether to also forbid a useful thing because of misguided efforts to impose a useless philosophy. Fortunately the answer was "no". > Talking about uneducated programmers how would you explain one of them > what and when will be visible? Ada's choice was to give a clear, > though unpleasant answer, rather than vague "yes, but". As I have said, it's extremely simple. Automatic variables are invisible.