length of an iolist

Scott Lystig Fritchie <>
Mon Aug 15 22:20:09 CEST 2005


>>>>> "ms" == Mark Scandariato <> writes:

ms> I originally had one, but I took it out since "iolist" is supposed
ms> to be a list.

I suspect that the name "i/o list"/"iolist"/whatever was coined before
the binary data type was added to Erlang ... so nowadays a proper
iolist may be either:

    * a (possibly deep) list of:
      - integers representing byte values
      and/or
      - binaries

    * a single binary

Looking in some old R9 documentation for gen_tcp:send/2:

    send(Socket, Packet) -> ok | {error, Reason}
    
    Types: 
       Socket = socket()
       Packet = list() | binary()
       Reason = atom()

Now that binaries are part of the language, it seems silly not to
include a single binary as a valid packet to send.  Ditto for a
function like file:write/2:

    write(IoDevice, Bytes)
    
        Writes Bytes (possibly a deep list of characters, or a binary) to the
        file described by IoDevice. [...]

Though neither definition really says that your (deep) list of
characters may also include binaries of arbitrary size.

Hm, in my R9 docs, "iolist" (and various spelling variations) do not
appear in .../kernel-2.9/doc/html/index.html index.  Does it appear in
the R10 docs?

-Scott
---
Scott Lystig Fritchie
Professional Governing: Is It Faked?



More information about the erlang-questions mailing list