Closed ddosia closed 9 years ago
The try-catch is outside the loop() call, and is just there to produce a helpful error report if the agent crashes. You'll find a similar construct in proc_lib:init_p(), which is used e.g. by gen_server:
https://github.com/erlang/otp/blob/maint/lib/stdlib/src/proc_lib.erl#L224
It's true that it leaves an entry on the stack, but it's only called once, so it won't blow the stack.
Educating, thanks, Ulf!
Am I right that try-catch block https://github.com/uwiger/locks/blob/master/src/locks_agent.erl#L228 prevents
loop
from tail recursion optimisation? I am trying to understand how locks works, thus I am not fully understand it's architecture. As far as I can see agents supposed to live the same amount of time as transactions does. Can it blow it's stack for this time if I am right?