lua-users home
lua-l archive

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




On Sat, Jun 22, 2019, 2:09 PM Andrew Gierth <andrew@tao11.riddles.org.uk> wrote:
>>>>> "Patrick" == Patrick Donnelly <batrick@batbytes.com> writes:

 Patrick> For io.lines, Lua automatically closes the file after the last
 Patrick> (successful) line. Unfortunately, there's no integration with
 Patrick> the generic for loop in Lua 5.4.

Huh?

In 5.4, io.lines explicitly _does_ integrate with the generic for loop
to ensure the file is closed (if it was opened and isn't just using
io.input). What makes you think there is not?


Sorry, I meant that there is no integration with generic for loop and the toclose variables, i.e. that breaking out of the for loop will cause the state value to be closed.