[erlang-questions] handling bugs in the program (was: nand problem)
Tue Jan 27 09:56:47 CET 2015
On Mon, Jan 26, 2015 at 10:35 PM, Joe Armstrong <erlang@REDACTED> wrote:
> by explicitly requiring the arguments of b_and to be true or false
> *and nothing else* you ensure that a program calling b_and with stupid
> arguments will crash *as soon as possible* which will make debugging
> easier. It also enables a whole bundle of compiler optimisations -
> making arguments more general than they need to be makes analysis more
> and compiled code more general. The more you tell the compiler, then
> better code it can produce.
> Yes the program is shorter (good) - but it's not totally correct (bad).
> This is not important for small programs, but for huge programs making every
> function totally correct is essential - correct well typed code can be written
> stuck in a library and forgotten forever - code that does silly things
> with silly
> arguments is not good programming practise.
> b_not should be defined over boolean arguments - any non boolean
> argument should raise an exception *immediately* anything else
> the principle of least astonishment.
does this also apply to messages which receiver is not expecting to
receive? If an unexpected message is received by a server, should it
In other words, should this be exit(badarg) instead?
More information about the erlang-questions