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,5afe598156615c8b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newspeer.monmouth.com!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Get_Line problem (GNAT bug?) Date: Thu, 07 Dec 2006 17:23:34 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1c1gbc5u9cpvp.1wj1zhhn7q86j$.dlg@40tude.net> <7fm8le.pa5.ln@hunter.axlog.fr> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls4.std.com 1165530220 7064 192.74.137.71 (7 Dec 2006 22:23:40 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 7 Dec 2006 22:23:40 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:k+sxGw5kEnRQLscOOyVrj3rZBes= Xref: g2news2.google.com comp.lang.ada:7856 Date: 2006-12-07T17:23:34-05:00 List-Id: Jean-Pierre Rosen writes: > Maciej Sobczak a �crit : >>> 3. As Adam has suggested, End_Error exception is the right design; >> I don't find it to be "right". For me, exception is something that is >> unexpected. An error, usually. > I beg to differ. Otherwise, they would be called "errors" or "abnormal". > An exception corresponds to an "exceptional" event, i.e. something that > prevents usual processing, and forces you to an exceptional handling. I basically agree with Jean-Pierre here. I like to put it this way: exceptions are for separating different parts of the software that have different views of what's an "error" and/or what to do about it. For example, extracting something from a container, when that "something" does not exist (because the container is empty, or the lookup fails, or whatever). From the point of view of the container package, this could be considered an "error". From the point of view of the client, it could be an error/bug, or it could be perfectly normal and recoverable. So the container raises an exception, and the client gets to decide what to do about it (handle the exception and continue, or write the client code so the exception won't happen, or ...). >.. If > you consider that normal processing (normally the body of a loop) is the > rule, it is an exception to the rule. Well, I'm not sure I agree with that. I mean, if you're looping through an array, you normally check against 'Last, via "while", or "exit when", of implicitly via "for I in X'Range...". You don't (normally) let your index go past the end, and then handle the Constraint_Error outside the loop. It seems like looping through a file ought be similar to looping through an array, in this regard. >...And EOF certainly matches this > definition (as is an error, of course, but it is not the only case). > > Exceptions are a useful tool in the programmers tool box. The narrow > view of exceptions as just a way to handle errors is a mistake that > prevents elegant solutions to some problems, in my view, and I've been > constantly fighting against that. Agreed -- if one says "exceptions are only for errors", then one has to define "error", and that's impossible, since "error" depends on the point of view. - Bob