lua-users home
lua-l archive

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


Am 21.02.2014 16:23 schröbte Javier Guerra Giraldez:
On Fri, Feb 21, 2014 at 10:14 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
For me, only text files have lines


i concur.

Me too, but the problem is that you can only find out if a file is a text file when you have read it from beginning to end. "Garbage in, garbage out" is ok for internal functions, but not for APIs exposed to the end-user. And reading files is always exposed to the user of the filesystem (with the possible exception of temp files).


i would even accept if io.lines() raised an error if called with a
file that wasn't opened in text mode.

`io.lines()` always opens the file in text mode, you probably meant `file:write()`. I wouldn't. I need binary streams for UTF-8, latin1, etc. (basically everything except ASCII) ...


of course, i much prefer the contract to be clearly stated "due to the
underlying old C implementation, embedded control characters can make
it return wrong results.  if you need to read binary data, use
file:read()"


Philipp