I’m posting this to force myself to remember what it means.
M : Module
F : Function
A : Arguments
Module, Function, Arguments.
pid = spawn(MyModule, :myfunc, [])
E.g.
iex(1)> pid = spawn(Explorate, :loop, []) #PID<0.123.0>
Can then send that pid a message.
defmodule Explorate do def loop do receive do { :hello } -> IO.puts "ahoy, shipmate!" _ -> IO.puts "Yous no ma shipmayte" end loop end end
Interactive Elixir (1.5.2) - press Ctrl+C to exit (type h() ENTER for help) iex(1)> pid = spawn(Explorate, :loop, []) #PID<0.123.0> iex(2)> send(pid, "ddd") Yous no ma shipmayte "ddd" iex(3)> send(pid, {:hello}) ahoy, shipmate! {:hello}
Note also to call loop again to recurse, otherwise you only get to call the pid once.