2 ms·
"It returns the exception so you can do something like case catch Expression of" Something to be aware of is the cost of a bare catch when an exception of t
by simoncion 11y ago
"It returns the exception so you can do something like
case catch Expression of"
Something to be aware of is the cost of a bare catch when an exception of type 'error' is thrown:
"[W]hen the exception type is 'error', the catch will build a result containing the symbolic stack trace, and this will then in the first case [1] be immediately discarded, or in the second case matched on and then possibly discarded later. Whereas if you use try/catch, you can ensure that no stack trace is constructed at all to begin with." [0]
Stack trace construction isn't free, so it makes sense to avoid it if you're not going to use it. I know that in either Erlang 17 or Erlang 18, parts of Mnesia were slightly refactored to move from bare catch to try/catch for this very reason.
[0] http://erlang.org/pipermail/erlang-questions/2013-November/075928.html http://erlang.org/pipermail/erlang-questions/2013-November/0...
[1] He's referring back to an example in the email
- toast0 11y agoThanks, I don't follow the mailing lists, so I probably wouldn't have known to think about that.