Здравствуйте, Mamut, Вы писали:
18 loop(S, NextP) ->
19 receive
20 % the message number is above zero => forward the message to the next
21 % process in the ring
22 R when R > 0 -> NextP ! R,
23 io:format(“: Proc: ~8w, Seq#: ~w, Msg#: ~w ..~n“, [self(), S, R]),
24 loop(S, NextP);
25 % the message number is zero => forward message and terminate
26 R when R =:= 0 -> NextP ! R,
27 io:format(“* Proc: ~8w, Seq#: ~w, Msg#: terminate!~n“, [self(), S]);
28 % error: the message number is below zero => raise exception
29 R when R < 0 ->
30 erlang:error({“internal error”, “invalid message number”})
31 end.
Ай-ай-ай... Эрланг делает больше проверок, чем питон. По нормальному-то если писать, то должно быть так:
18 loop(S, NextP) ->
19 receive
26 0 -> NextP ! 0,
27 io:format(“* Proc: ~8w, Seq#: ~w, Msg#: terminate!~n“, [self(), S]);
20 % the message number is above zero => forward the message to the next
21 % process in the ring
22 R -> NextP ! R,
23 io:format(“: Proc: ~8w, Seq#: ~w, Msg#: ~w ..~n“, [self(), S, R]),
24 loop(S, NextP);
25 % the message number is zero => forward message and terminate
31 end.
Во вторых, надо убрать io — сейчас все затыкается в него.