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,7728b533f7ab5fb6 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!cyclone1.gnilink.net!gnilink.net!nx02.iad.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!feeder.news-service.com!newsfeed1.swip.net!newsfeed1.funet.fi!newsfeeds.funet.fi!nntp.inet.fi!central1.inet.fi!inet.fi!read4.inet.fi.POSTED!53ab2750!not-for-mail Sender: AWI003@FIW9752 Newsgroups: comp.lang.ada Subject: Re: Avoiding side effects References: From: Anders Wirzenius Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: Tue, 30 Sep 2008 12:43:29 GMT NNTP-Posting-Host: 194.251.142.2 X-Complaints-To: abuse@inet.fi X-Trace: read4.inet.fi 1222778609 194.251.142.2 (Tue, 30 Sep 2008 15:43:29 EEST) NNTP-Posting-Date: Tue, 30 Sep 2008 15:43:29 EEST Organization: Sonera Customer Xref: g2news1.google.com comp.lang.ada:2162 Date: 2008-09-30T12:43:29+00:00 List-Id: Jean-Pierre Rosen writes: > Anders Wirzenius a �crit : > > Please don't feel like I am provocative. I just want to find out > > the difference between exceptions and side effects: > > Why is an exception in this case not considered to be a side > > effect? > > > To me, an exception is more like a kind of result rather than a side-effect. > > A subprogram is intended to provide a certain service; either it can > provide the intended result, or it must tell the caller, in an > unambiguous way, that the correct result could not be provided; that's > what exceptions are for. > > If you compare exception with a return code, the difference is that > you can easily ignore a return code, but not an exception. And > remember: > "There is only one thing worse than a program that crashes: > a program that gives wrong, but likely results." Thanks for this excellent clarification. Actually there exists already occurrences of an exception in both functions. To "translate" those Ada.Text_IO.End_Of_File (...) occurrences to a global EOF_variable is just clumsy. Much better to use the exceptions directly in the main program. Thanks for your time. -- Anders