Proposal: Extensible exceptions
David Menendez
dave at zednenem.com
Sun Jul 6 19:24:19 EDT 2008
On Sun, Jul 6, 2008 at 6:05 PM, Henning Thielemann
<lemming at henning-thielemann.de> wrote:
>
>> While dividing by zero or accessing an array out of bounds isn't the
>> same as a file not existing, I'm not sure we need different mechanisms
>> for dealing with them.
>
> Yes! Because there is no need to recover from an error. Instead an error
> must be fixed by the programmer. The program cannot do this by itself. I
> consider recovering from an error like in a web-server a hack, like catching
> and recovering from an 'error' in IO is a hack, just like unsafePerformIO. I
> accept that we need a hack in order to tell the user "please send a
> bug-report to XYZ", but a hack should be called a hack, not "proper
> exception handling".
I don't recall calling anything "proper exception handling". I said
that it's reasonable to report certain programming errors through the
exception handling mechanism because it allows a running program to
clean up before it terminates.
>> If your code divides by zero, you still want any "finally" or "bracket"
>> clauses to get called before the program terminates.
>
> A program which divides by zero is broken and must be fixed. A program which
> divides by zero but cleans up a bit, is still broken and must be fixed.
> Cleaning up may make things better, but may also make things worse! Handling
> errors is the task of Debugging, not that of Exception Handling. I suggest
> special variants of 'finally' and 'bracket' for bracketing bugs should be
> located below "Debug" in the module hierarchy.
Yes, a program that divides by zero should be fixed. If a program has,
say, locked a file and then encounters an error, are you suggesting
that the program should crash without unlocking the file? The fact
that the program shouldn't have encountered an error is irrelevant.
--
Dave Menendez <dave at zednenem.com>
<http://www.eyrie.org/~zednenem/>
More information about the Libraries
mailing list