Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

An `iolist()` or `iodata()` structure is mainly designed for I/O.

The idea is rather simple but powerful.

Let's say you want to send `"Hello " + name`, where `name` is a string, over the network. Traditionally, in C, you would allocate a buffer that is large enough and copy the "Hello " literal into it and then copy the `name` string before calling `write(fd, buffer, length)`.

If you wanted to avoid allocating the buffer and doing the copy, you would make use of `writev(fd, iovec, count)`, and this is exactly what the `iolist()` structure allows for. The erlang runtime system (erts) makes use of efficient `writev` calls instead of having to allocate temporary buffers just to send data over the network (something Erlang is notoriously good at) when you make use of `iolists`.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: