lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 6 September 2016 at 17:59, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> I found (slightly to my surprise) that io.read under Linux does not
> discard the \r character when given files with \r\n line endings.
>
> First issue: is keeping `\r' a bug, an implementation detail, or a feature?

This is a specified feature of libc.

> I also found (slightly to my surprise) that io.lines and file.lines have
> nothing to do with each other. io.lines does not operate by assigning
> a default file if needed and invoking file.lines. Instead, both invoke
> an auxiliary function, not exposed at the Lua level.
>
> Second issue: is this an implementation detail, or a feature?

Feature. io.lines uses a different code path so that it can call
close() automatically on the last loop iteration (instead of waiting
around for the garbage collector)