lua-users home
lua-l archive

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




Il mer 12 giu 2019, 16:28 Doug Currie <doug.currie@gmail.com> ha scritto:
local contents
local f = io.open("myfile")
do
    contents = f:read()
finally
    f:close()
end

Imho this miss the point even more since the closing stuff is very distant from the initialization. What is the difference with just calling "close" at end of the scope?

The intent here is that the code in the `finally` section is called regardless of how the scope is exited: normal exit, exception, coroutine.close, etc.

Ok, you got a point. However it can still be far away from the initialization, being very error prone. Moreover I think it can easily become an "Nesting hell"