Erlang - whereis



它被稱為 whereis(Name)。返回註冊了該名稱的程序的 pid。

語法

whereis(atom,pid)

引數

  • 原子 - 這是要賦予程序的註冊名稱。

返回值

繫結到原子的程序 ID。

例如

-module(helloworld). 
-export([start/0, call/2]). 

call(Arg1, Arg2) -> 
   io:fwrite("~p~n",[Arg1]). 

start() -> 
   Pid = spawn(?MODULE, call, ["hello", "process"]), 
   register(myprocess, Pid), 
   io:fwrite("~p~n",[whereis(myprocess)]).

輸出

當我們執行上述程式時,我們將獲得以下結果。

<0.55.0>
"hello"
erlang_processes.htm
廣告

© . All rights reserved.