From 223bb04090344b1972dc2a7910a54b46210f0d40 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 31 Jul 2019 11:41:59 -0300 Subject: Correction in the documentation of 'io.lines' The loop does not end on end of file, but when the iterator function fails to read a value. (In particular, the format "a" never fails, so a loop with 'io.lines(fname, "a")' never ends.) --- manual/manual.of | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'manual') diff --git a/manual/manual.of b/manual/manual.of index 8eebe9cb..c1ee8eb7 100644 --- a/manual/manual.of +++ b/manual/manual.of @@ -7926,8 +7926,8 @@ instead of returning an error code. Opens the given file name in read mode and returns an iterator function that works like @T{file:lines(@Cdots)} over the opened file. -When the iterator function detects the end of file, -it returns no values (to finish the loop) and automatically closes the file. +When the iterator function fails to read any value, +it automatically closes the file. Besides the iterator function, @id{io.lines} returns three other values: two @nil values as placeholders, @@ -7941,7 +7941,8 @@ to @T{io.input():lines("l")}; that is, it iterates over the lines of the default input file. In this case, the iterator does not close the file when the loop ends. -In case of errors this function raises the error, +In case of errors opening the file, +this function raises the error, instead of returning an error code. } @@ -8053,9 +8054,6 @@ starting at the current position. Unlike @Lid{io.lines}, this function does not close the file when the loop ends. -In case of errors this function raises the error, -instead of returning an error code. - } @LibEntry{file:read (@Cdots)| -- cgit v1.2.3-55-g6feb