lua-users home
lua-l archive

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


D Burgess wrote:
Now that 5.1 is near enough to finalized, here is my request for
change for 5.11.

A colleague of mine provided me with a modified io.lines (named io.linex)
that is similar to the original but differs as follows:

1) a line is defined as something that is terminated by either "\n" or "\f"
2) leading and trailing "\r" s are removed from the line before it is
returned. This feature may be optionally disabled.
3) The iterator returns 2 values rather than 1. The second value is the
line terminator. e.g. "\n" or "\f"

Other than the changes above this performs the same as io.lines/fh:lines.

I have tested and used this on win32 and linux.

I argue the case for its inclusion in Lua because I find the iterator
invaluable in processing report files from various applications from
OSs. It sanely handles combinations like CRLF, LF, CRFF, FF, CRFFCR
etc., keeps the string processing in C rather than Lua
whilst keeping the lua read loops simple.

David Burgess


I like the TCL stackable channels model for all io. Line termnination handling is stacked, as needed, on top of the raw io channel. Ditto for things like encryption, etc.

Also the notion in Python of being able to refer to, for instance, "os" and have "os.linux" or "os.windows", etc. transparently loaded based on the current platform to give the best implementation available for the platform. The base "os" module describes the available functionality, sort of like an abstract class.

Dave LeBlanc
Seattle, WA USA