lua-users home
lua-l archive

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




On 06/09/16 05:05 AM, Daurnimator wrote:
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)

I think io.lines doesn't call close if you call it with nil as the file? I might be wrong tho...

--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.