Small poll
Joachim Durchholz
joachim.durchholz@REDACTED
Fri Dec 19 10:04:58 CET 2003
Chris Pressey wrote:
> Bengt Kleberg <Bengt.Kleberg@REDACTED> wrote:
>
>> Chris Pressey wrote:
>>
>> yes, i am all for letting code crash. i just do not think it is
>> usefull to let the compiler produce code for a module that will
>> always crash because potentially correct code is written in such a
>> way as to produce a runtime error.
>>
>> use erlang:throw/1 or erlang:exit/1 if an runtime error is what you
>> want.
>
> You're of course entitled to hold any opinion you wish, but I really
> have to say that I disagree, and that I can't quite see your
> reasoning.
>
> In Erlang as we know it, a + 42 generates an exception. An exception
> is by definition not a show-stopper; it can be caught and acted upon.
> But by changing it into a compile-time error, you're not even giving
> the program an *opportunity* to crash. This runs against the "let it
> crash" philosophy in my book.
I think you're misunderstanding Chris. I don't remember him advocating
adding a
_ = throw ("No pattern matched for function foo")
clause to every function. He's advocating replacing
a + 42
with
throw ("Not Implemented Yet")
and I'd like to join in: `throw' tells the reader that the error was
intentional, and its argument provides information why the crash was
programmed and whether that's a temporary or permanent decision. That's
*far* better than `a + 42'.
`a + 42' is a cute trick - and cute tricks should be avoided since they
make software less maintainable, at least in my experience; software
should explicitly state what it does, and not rely on implicit behaviour
- I know that both constructing and deciphering cute tricks can give
enormous mental satisfaction, but the downside is that the code will be
readable for a slightly smaller fraction of programmers, and that's an
unacceptable side effect. IMHO.
Regards,
Jo
More information about the erlang-questions
mailing list