[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Cross-platform reading of text files
- From: "Soni L." <fakedme@...>
- Date: Tue, 6 Sep 2016 06:45:16 -0300
On 06/09/16 05:05 AM, Daurnimator wrote:
I think io.lines doesn't call close if you call it with nil as the file?
I might be wrong tho...
On 6 September 2016 at 17:59, Dirk Laurie <email@example.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)
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.