Ive heard its a bad idea to program defensively in Erlang. Why?
The Erlang coding guidelines suggest avoiding defensive programming. The choice of the term “defensive programming” is unfortunate, because it is usually associated with good practice. The point of the recommendation is that allowing an Erlang process to exit when things go wrong inside the Erlang program is a good approach, i.e. writing code which attempts to avoid an exit is usually a bad idea. For example, when parsing an integer it makes perfect sense to just write I = list_to_integer(L) if L is not an integer, the process will exit and a supervisor somewhere will restart that part of the system, reporting an error: =ERROR REPORT==== 12-Mar-2003::13:04:08 === Error in process <0.25.0> with exit value: {badarg,[{erlang,list_to_integer,[bla]},{erl_eval,expr,3},{erl_eval,exprs,4},{shell,eval_loop,2}]} ** exited: {badarg,[{erlang,list_to_integer,[bla]}, {erl_eval,expr,3}, {erl_eval,exprs,4}, {shell,eval_loop,2}]} ** If a more descriptive diagnostic is required, use a manual exit: upper