Erlang – whereis

Erlang whereis

In this guide, we will discuss Erlang Whereis. It is called as whereis(Name). Returns the pid of the process that is registered with the name.

Syntax

whereis(atom,pid)

Parameters

  • atom − This is the registered name to give to the process.

Return Value

The process id bound to the atom.

For example

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

Output

When we run the above program, we will get the following result.

<0.55.0>
"hello"

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply