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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7d3cb5920e882220 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!e25g2000prg.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Exceptions Date: Thu, 13 Dec 2007 06:00:31 -0800 (PST) Organization: http://groups.google.com Message-ID: <9f16235c-260a-460b-873c-2183c154cc0c@e25g2000prg.googlegroups.com> References: <5947aa62-2547-4fbb-bc46-1111b4a0dcc9@x69g2000hsx.googlegroups.com> <475c688f$0$17524$9b4e6d93@newsspool4.arcor-online.net> <4dae26fe-0c8a-46e1-9a33-43c18cf757ae@i3g2000hsf.googlegroups.com> NNTP-Posting-Host: 85.3.91.186 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1197554431 14202 127.0.0.1 (13 Dec 2007 14:00:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 13 Dec 2007 14:00:31 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e25g2000prg.googlegroups.com; posting-host=85.3.91.186; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8.0.1) Gecko/20060317 Firefox/1.5.0.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:18921 Date: 2007-12-13T06:00:31-08:00 List-Id: On 13 Gru, 14:40, Robert A Duff wrote: > The solution to "when others => null;" and the like is better > education. Isn't it also a solution for all the presumed problems of C/C++? Sorry, could not resist. ;-) > I don't consider Constraint_Error "mere", by the way. > It almost always represents a bug. What about a situation when a user entered an input data that was outside of legal (and documented) range? Or that caused our of range value further down the pipe? This is not necessarily a bug, just an indication that the value is out of range. The exception can help to come back to the input loop and repeat the user scenario, abandoning all the state that was created in the meanime. This way the program does not enter into any abnormal state. > > Why not terminating the program right on the spot by simply: > > > pragma Assert (False); > That doesn't terminate the program on the spot. > It raises Assertion_Failure. Right. I was somehow convinced that Assert has this magic property of switching the world off, like the assert macro in C and C++. > I consider all of these: > > pragma Assert (False); > Assert (False); -- Assert is a user-defined procedure > raise Program_Error; > raise Bug; -- Bug is a user-defined exception used project-wide > > to be legitimate ways of reporting a self-detected bug. OK, this sounds reasonable. > There ought to be a standard predefined procedure for stopping the > program "on the spot". Since there isn't, you can import "exit". I was wandering whether there is any standard mechanism for this. -- Maciej Sobczak * www.msobczak.com * www.inspirel.com