在上一篇Elixir IO內幕(一)讀操做中,咱們看到了Elixir是怎麼實現讀IO的。那麼此次就來看看怎麼寫IO。.net
寫IO其實比讀要簡單,由於它只有下面幾種消息:code
{:io_request, sender_pid, reference, {:put_chars, chars}} {:io_request, sender_pid, reference, {:put_chars, encoding, chars}} {:io_request, sender_pid, reference, {:put_chars, mod, func, args}} {:io_request, sender_pid, reference, {:put_chars, encoding, mod, func, args}}
後兩種仍是不知道對應什麼,可是前兩種對應啥應該不用我說了吧?blog
並且寫操做的正常回復只有兩種:get
{:io_reply, reference, :ok} {:io_reply, reference, {:error, reason}}
不用多寫了吧?io