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,5117b1b6391a0e06 X-Google-Attributes: gid103376,public Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: A simple ADA puzzle (I haven't the answer) Date: Mon, 21 Jun 2004 10:16:36 +0200 Message-ID: <2i5dd0lu0i3a8bokfh7916r4j67g42ri4o@4ax.com> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de rnHYr6n8K4NgafD+PMHC0AsohP1BRzu6Pu+wiYO8DIXadMp0k= X-Newsreader: Forte Agent 1.8/32.548 Xref: g2news1.google.com comp.lang.ada:1726 Date: 2004-06-21T10:16:36+02:00 List-Id: On Mon, 21 Jun 2004 03:30:32 GMT, Hyman Rosen wrote: >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. I usually put helper classes in the class of the object, but it is a matter of taste. >> 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. Same fault as in Ada. There should be routine types, which in most cases would eliminate any need in pointers. >So it is clear that access to >local variables will never be permitted. So it is inconsistent. >The question is then >whether to also forbid a useful thing because of misguided efforts >to impose a useless philosophy. That's another philosophy, the C++'s one: quick and dirty, or rather "let's first make it dirty, maybe it happens to be quick". >Fortunately the answer was "no". One cannot correct one error by making another. >> 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. Huh, how is it better than Ada's limitation on tagged types? -- Regards, Dmitry Kazakov www.dmitry-kazakov.de