On 08/09/2012 10:45 AM, Aleksandr Vinokurov wrote:
>
>
> Hello all
>
> I've found the subject and did not understand the root of such
> restriction: why io:format/2 can't understand iolist for a Format arg?
In order to interpret the Format argument, it would need to flatten the
iolist first anyway. For example, io:format(["~",[<<"w">>]], [Term]).
It's simply easier from the library's point of view to just say that the
Format argument needs to be a flat string (guaranteeing that there's no
needless overhead for flattening in the majority of cases), and if you
have an iolist, then define your own format function like this:
format(IOList, Args) ->
io:format(binary_to_list(erlang:iolist_to_binary(IOList)), Args).
/Richard
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions