lua-users home
lua-l archive

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


On Feb 20, 2014, at 3:50 PM, Cezary H. Noweta <chn@poczta.onet.pl> wrote:

> On 2014-02-20 21:15, René Rebe wrote:
> 
>> On Feb 20, 2014, at 21:03 , Dirk Laurie wrote:
> 
>>> 1. io.lines operates on text files.
> 
>> lines operates on streams, which on most platforms these days only
>> operate in binary mode anyway.
> 
> Is there an official standard for this?
> 

The entire text/binary mode thing was more-or-less cooked up for CP/M and MSDOS use of CR+LF as a line terminator. It’s a complete mess since it’s not even really a “mode”, just a hack to handle line termination. Prior to this, C runtimes always opened files in one mode: a stream of bytes that could be interpreted as text or not depending on which read/write APIs you called.

The real problem here really is that the ANSI C standard was very late in arriving and by that time it wasn’t so much that they defined a rational runtime design, it was more an attempt to document the lowest-common denominator amongst observed behaviors of the various ad-hoc clones of the Unix runtime. Anyone who has had to deal with the subtleties of realloc() or strncpy() can attest to that.

—Tim