Erlang - Whereis

Il est appelé whereis (Nom). Renvoie le pid du processus qui est enregistré avec le nom.

Syntaxe

whereis(atom,pid)

Paramètres

  • atom - Ceci est le nom enregistré à donner au processus.

Valeur de retour

L'identifiant de processus lié à l'atome.

Par exemple

-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)]).

Production

Lorsque nous exécutons le programme ci-dessus, nous obtiendrons le résultat suivant.

<0.55.0>
"hello"