size of an IO list
Bjorn Gustavsson
bjorn@REDACTED
Mon Mar 7 11:20:18 CET 2005
As usual, the hardest part is usually coming up with a good name.
After some discussion, Kenneth and I come up with the following
suggestion for TWO new BIFs.
iolist_size(IOList)
iolist_to_binary(IOList)
where iolist_to_binary/1 will work like this
iolist_to_binary(IOList) ->
size(list_to_binary([IOList])).
but be much faster (and obviously not build the temporary binary).
The reason for the new iolist_to_binary/1 BIF is that is not clear
that iolist_size/1 is any way releated to list_to_binary/1.
Comments? Other name suggestions?
/Bjorn
"Joe Armstrong \(AL/EAB\)" <joe.armstrong@REDACTED> writes:
> How about a BIF to compute the size of an I/O list?
>
> Why?
>
> I have made a deep list that I want to output (guess what's it's HTML :-)
>
> I need to make an HTTP header element "Content-Length: ..."
>
> Which is the size of the flattened deep list , but I don't want to flatten it (horrors)
> or traverse it (in Erlang) to find the length.
>
> Suitable case for a BIF?
>
> /Joe
>
--
Björn Gustavsson, Erlang/OTP, Ericsson AB
More information about the erlang-questions
mailing list