Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Ive heard its a bad idea to program defensively in Erlang. Why?

0
10 Posted

Ive heard its a bad idea to program defensively in Erlang. Why?

0

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

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123