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 Path: g2news1.google.com!postnews.google.com!e53g2000hsa.googlegroups.com!not-for-mail From: Martin Newsgroups: comp.lang.ada Subject: Re: About String Date: Sun, 8 Jun 2008 04:48:56 -0700 (PDT) Organization: http://groups.google.com Message-ID: <4379495d-186e-418b-91b8-92b4da991807@e53g2000hsa.googlegroups.com> References: <484ABED3.8040909@obry.net> <484b802a$0$23844$4f793bc4@news.tdc.fi> NNTP-Posting-Host: 20.133.0.8 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1212925736 20562 127.0.0.1 (8 Jun 2008 11:48:56 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 8 Jun 2008 11:48:56 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e53g2000hsa.googlegroups.com; posting-host=20.133.0.8; posting-account=g4n69woAAACHKbpceNrvOhHWViIbdQ9G User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9) Gecko/2008052906 Firefox/3.0,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:612 Date: 2008-06-08T04:48:56-07:00 List-Id: On 8 Jun, 08:35, "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. > > > I wonder if it would be a good idea for Ada to allow an exception > > handler also in the "declare" part, as follows: > > > =A0 =A0 -- NOT Ada! > > =A0 =A0 declare > > =A0 =A0 exception > > =A0 =A0 begin > > =A0 =A0 exception > > =A0 =A0 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: > > package A is > =A0 =A0 > exception > =A0 =A0 =A0(:-)) > end A; Admittedly the range of options is pretty limited if exception handlers where to be added to package specs but you could log an indication in a package local variable, set a default or re-raise the exception. I rather like the idea...that forced nesting just to catch an exception is quite ugly and dare I day, goes against Ada's "easy to read and therefore maintain" mantra... Cheers -- Martin