Posts

Showing posts from January, 2016

Process Communication in Erlang

Image
Hi there! In erlang, no process talks directly to each other. You can think of it as a process in erlang has locked itself up in a room. And it is very workaholic. It loves doing its own work. What about Concurrency and inter process communication? Your one process can mail other process with required details and ask it to work on the data. (Erlang processes are workaholic). You just need the address of the process (the Process ID or the PID for this). Lets take a very simple example, where in the erlang process prints the sound of the animal. ==================== -module(animal_sound). -compile(export_all). sound()-> receive dog -> io:format("bhuw bhuw"); cat -> io:format("Meow"); _ -> io:format("Whisperings!") end. ==================== Save as animal_sound.erl, compile and run. Note : compile(export_all) can be used when you want all your functions to be visible to the outside world. Else you can export onl