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!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.velia.net!goblin2!goblin.stu.neva.ru!fi.sn.net!newsfeed1.fi.sn.net!news.song.fi!not-for-mail Date: Sun, 08 Jun 2008 14:14:04 +0300 From: Niklas Holsti User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060628 Debian/1.7.8-1sarge7.1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: About String References: <484ABED3.8040909@obry.net> <484b802a$0$23844$4f793bc4@news.tdc.fi> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <484bbea5$0$2673$4f793bc4@news.tdc.fi> Organization: TDC Internet Services NNTP-Posting-Host: laku61.adsl.netsonic.fi X-Trace: 1212923557 news.tdc.fi 2673 81.17.205.61:32878 X-Complaints-To: abuse@tdcnet.fi Xref: g2news1.google.com comp.lang.ada:610 Date: 2008-06-08T14:14:04+03:00 List-Id: Dmitry A. Kazakov wrote: > On Sun, 08 Jun 2008 09:47:30 +0300, Niklas Holsti wrote: > > >>The solution is just to add one more "begin..end" block, enclosing >>the "declare .. begin .. end", and handle the exceptions in this >>outer "begin..end" block. Or handle the exceptions in the >>subprogram's "begin..end" block and nest the "declare..begin..end" >>within the subprograms "begin..end". >> >>That said, I admit that I, too, have made this mistake once or >>twice. But not lately. > > > If exceptions were contracted such, quite nasty, errors could be detected > at compile time. Only if the programmer specifies the exception contracts separately for the declarative parts and the statements. I don't remember any such proposals. >>I wonder if it would be a good idea for Ada to allow an exception >>handler also in the "declare" part, as follows: >> >> -- NOT Ada! >> declare >> exception >> begin >> exception >> end; >> >>Of course, in this proposal the declaration-exception handler would >>not have access to the declared variables. > > > But then, for regularity sake, you would need to add exception handling to > all declarative parts: And why not? > package A is > > exception > (:-)) > end A; It seems, from your smiley, that you feel that such a structure would be somehow impossible. I don't see why; the exception handler could execute any sort of non-erroneous code that could be executed in any subprogram called as part of the declarations in package A. For example, it could set some flag in another package to inform the application that package A cannot be used because its elaboration failed. If the application uses run-time elaboration checks, it could even continue executing, as long as it does not try to use anything in A. I admit that this might need an extended form of run-time elaboration checks. I'm not suggesting that this feature (exception handlers in package declarations) is desirable, but I don't think it would be impossible, and it could even be useful in some applications. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .