From: Anders Wirzenius <anders@no.email.thanks.invalid>
Subject: Re: Avoiding side effects
Date: Tue, 30 Sep 2008 12:43:29 GMT
Date: 2008-09-30T12:43:29+00:00 [thread overview]
Message-ID: <uy7197qj2.fsf@no.email.thanks.invalid> (raw)
In-Reply-To: ov2tbg.9sc.ln@hunter.axlog.fr
Jean-Pierre Rosen <rosen@adalog.fr> 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
next prev parent reply other threads:[~2008-09-30 12:43 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-30 5:50 Avoiding side effects Anders Wirzenius
2008-09-30 7:48 ` Jean-Pierre Rosen
2008-09-30 9:20 ` Anders Wirzenius
2008-09-30 11:36 ` Jean-Pierre Rosen
2008-09-30 12:43 ` Anders Wirzenius [this message]
2008-09-30 10:42 ` Ludovic Brenta
2008-09-30 11:12 ` Anders Wirzenius
2008-10-02 12:56 ` Ole-Hjalmar Kristensen
2008-10-06 12:09 ` Anders Wirzenius
2008-10-07 11:08 ` Ole-Hjalmar Kristensen
2008-10-07 14:24 ` (see below)
2008-10-07 14:47 ` Anders Wirzenius
2008-10-07 14:51 ` (see below)
2008-10-08 5:16 ` Anders Wirzenius
2008-10-08 7:35 ` Dmitry A. Kazakov
2008-10-08 15:32 ` (see below)
2008-10-13 12:27 ` Anders Wirzenius
2008-10-13 13:21 ` Marco
2008-10-13 18:55 ` (see below)
2008-10-14 7:30 ` Dmitry A. Kazakov
2008-10-14 11:44 ` Colin Paul Gloster
2008-10-13 18:49 ` (see below)
2008-10-13 21:22 ` Adam Beneschan
2008-10-13 21:53 ` (see below)
2008-10-14 6:17 ` mockturtle
2008-10-14 14:58 ` Adam Beneschan
2008-10-14 6:22 ` Avoiding side effects and other dogma Anders Wirzenius
2008-10-14 13:48 ` (see below)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox