[erlang-questions] Line Receiver example?

Geoff Cant nem@REDACTED
Mon Apr 27 22:56:11 CEST 2009

Jarrod Roberson <jarrod@REDACTED> writes:

> On Mon, Apr 27, 2009 at 3:59 PM, Per Melin <per.melin@REDACTED> wrote:
>> Jarrod Roberson:
>> >  io:format("Received Line:~p~n", binary_to_list(Bin)),
>> This line is broken. Your process crashes. Do this:
>> io:format("Received Line:~p~n", [binary_to_list(Bin)]),
> just for future knowledge why are the [] required around the list?

Erlang doesn't do varargs, so we use lists as arguments instead
(io:format/2 takes a number of arguments depending on the format string
- io:format("~p", [Arg1]), io:format("~p ~p", [Arg1, Arg2]) not
io:format("~p ~p", Arg1, Arg2) as that would change the arity of the
function from io:format/2 to io:format/3 which does something quite

Geoff Cant

More information about the erlang-questions mailing list