ฉันกำลังอ่าน การเขียนโปรแกรม Erlang โดย Joe Armstrong(Pragmatic Bookshelf) ในซอร์สโค้ด name_server.erl ในบทที่ 16 ตัวแปร Dict มาจากไหน การเรียก dict:new() สร้าง Dict โดยอัตโนมัติหรือไม่ และการอ้างอิงบอกว่า dict:new() สร้างพจนานุกรม ฉันไม่จำเป็นต้องเก็บมันเป็นตัวแปรเช่น Dict = dict:new() ใช่ไหม
-module(name_server).
-export([init/0, add/2, whereis/1, handle/2]).
-import(server1, [rpc/2]).
add(Name, Place) ->
rpc(name_server, {add, Name, Place}).
whereis(Name) ->
rpc(name_server, {whereis, Name}).
init() ->
dict:new().
handle({add, Name, Place}, Dict) ->
{ok, dict:store(Name, Place, Dict)};
handle({whereis, Name}, Dict) ->
{dict:find(Name, Dict), Dict}.