
Judah Jacobson wrote:
On Mon, Feb 4, 2008 at 6:06 AM, Yitzchak Gale
wrote: Simon Marlow wrote:
However, I do agree that exceptions should generally be used for exceptional conditions, rather than for general control-flow. This is an example of a *good* reason to avoid an exception: because to use an exception for a non-exceptional condition is poor style.
That is also my opinion. Some people have disagreed. So this should be the focus of the decision then.
I also agree that exceptions should only be used for exceptional conditions; but I do think that this is one of those situations. I'll try to explain why below. (Thanks, Yitzchak, for forking off the thread about fixing limitations of MonadIO.)
I assume that the following conditions are already considered exceptional (I haven't ever heard anyone complain that they throw an exception): - readFile : read a nonexistent file - writeFile : write to a file in a nonexistent directory - getEnv: retrieve an unset environmental variable
FWIW, this was hotly debated at the time, and I do believe we made the wrong decision w.r.t. getEnv, mainly because I always end up writing "try $ getEnv", or I forget the try and have to fix the bug later. Cheers, Simon