[erlang-questions] Why io::format() type is not an iolist?
Wed Aug 15 21:03:57 CEST 2012
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) ->
More information about the erlang-questions