Defensive programming in Erlang

The following lines appear in http://aosabook.org/en/riak.html in the second paragraph of the section: 15.1. Short introduction to Erlang :

"Calling a function with a negative number will result in a runtime error, since none of the sentences matches. Do not handle this case is an example of unprotected programming, a practice encouraged in Erlang."

Two questions: what is the idiomatic way of handling the error in Erlang; and why is it better than covering all cases explicitly, like in languages ​​like OCaml or Haskell?

+4
source share
1 answer

, , 3 :

  • , , .

  • , OTP, OTP, .

  • "", .

: . Erlang try catch OTP .

( , ) .

, erlang , , , , , .

- learnyousomeerlang, 3 , :

  • ?
+8

Source: https://habr.com/ru/post/1609227/


All Articles