5

Erlang では、すべてのプロセスにグループ リーダーがあり、プロセスが何かを出力したい場合 (つまり、io ライブラリを呼び出すか、同様のことを行う場合)、グループ リーダーにメッセージを送信します。

私の質問は、これらのメッセージの仕様はどこにありますか? それとも、一般的に、グループ リーダーが何をすべきかの仕様ですか?

{io_request, Sender, GroupLeader, Request}いくつかの実験で、プロセスが用語を送信し、答えが用語であることがあることがわかりましたが{io_reply, GroupLeader, ok}、他の場合もあるかもしれません。

4

2 に答える 2

6

Erlangの理論的根拠(ビデオ)または(スライド) ; user.erlのソースコードと同様に、は優れた情報源です。

要するに:

  {io_request, From, ReplyAs, Request}
  %From is the process to send the reply to, 
  %ReplyAs is any term the caller desires to 
  %match up the request and the response. (returned verbatim in the reply)
  {io_reply, ReplyAs, Reply}

user.erlのいくつかのリクエスト:

 {put_chars, IoList} % puts the iolist
 {put_chars, M,F,A} % puts the result of apply(M,F,A)
 {get_geometry, 'rows' | 'columns'} % returns the number of rows or columns of the console
 {get_line, Prompt} % calls io_lib:collect_line(Prompt)
 {get_chars, Prompt, Mod, Func, ExtraArgs} 
 {get_until, Prompt, Mod, Func, Args}
 {setopts, Options} % only option supported by user is 'binary' 
                    % (binary mode if present in Options, list mode otherwise)
于 2008-11-17T18:59:03.283 に答える
1

Erlang I/O プロトコルの詳細については、次を参照してください。

http://www.erlang.org/doc/apps/stdlib/io_protocol.html

于 2013-10-20T15:56:57.290 に答える