The following code snippet appeared on page 352:<br><br>-module(sellaprime_supervisor). <br>-behaviour(supervisor). % see erl -man supervisor <br>-export([start/0, start_in_shell_for_testing/0, start_link/1, init/1]). <br>
<br>start() -> spawn(fun() -> <br> supervisor:start_link({local,?MODULE}, ?MODULE, _Arg = []) <br> end). <br><br>start_in_shell_for_testing() -> <br> {ok, Pid} = supervisor:start_link({local,?MODULE}, ?MODULE, _Arg = []),
<br> unlink(Pid). <br><br>%% rest of the code intentionally left out<br><br>Question 1:<br><br>What's the benefit to call spawn for supervisor:start_link in the start() function? Why not just call supervisor:start_link without the spawn? Doesn't supervisor:start_link already spawn and register the process already?
<br><br>Question 2:<br><br>What's the benefit for start_in_shell_for_testing() function? Why not just call start() function when testing in the shell? I know what the unlink(Pid) does, but why unlinking it? What if unlink it left out?
<br><br>Question 3:<br><br>I don't understand _Arg = [] ? why not just pass [] as the last argument of start_link?<br><br>Thanks in advance,<br><br>Aaron<br>