lua-users home
lua-l archive

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


> There's a few solutions I can think of to the newlines problem:
> + Add a new extra boolean parameter to io.lines() to specify that you
> want to preserve them
> + Allow functions passed to load() to return multiple strings instead
> of just the one, and change io.lines() iterators to yield two results
> each time, the line and the new line character(s)
> + Add a new function, a generalised form of io.lines(), something like
> io.reader(filename, format) where 'format' is the same kind of thing
> as the argument(s) passed to file:read(). If you pass "*l", the
> iterator returned is identical to one created by io.lines() (and would
> have the same problem); you could instead pass a number or "*a", which
> would create an iterator that would not strip the newlines.
> 
> Personally I like the third option, as it seems like a more general
> solution. Any which way, I think it is worth finding a good solution
> in time for the final release of 5.2.

We implemented the first option, but currently we are inclined to the
third one. As Steve pointed out, it would have other uses too.

-- Roberto