lua-users home
lua-l archive

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


On Tue, Aug 25, 2009 at 2:38 AM, Alexander Gladysh<agladysh@gmail.com> wrote:
> It looks like while file.lines perhaps does not close the file, it
> does not seek it back to beginning. Furthermore, it looks like all
> iterators to the same file do use the same file position pointer.

The way i see it is that the file object owns the position pointer, as
typical on most I/O libraries.  On top of that, you could read() by
line, which advances file object's pointer (as expected).  the lines()
iterator is just a convenient way to do the same reading, it doesn't
have its own position pointer, but still uses the file object's one.

that way, you could use the same file object to get the position from
within the loop, or even advance the position.

it's just a matter of recognizing who owns what.

-- 
Javier