lua-users home
lua-l archive

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


вт, 16 июл. 2019 г. в 00:23, Gé Weijers <ge@weijers.org>:
>
>
> Something like his (untested):
>
> local function close_values(t)
>   for _, val in pairs(t) do
>     local <toclose> tmp = val
>   end
> end
>
> local <toclose> array = setmetatable({}, {__close = close_values})
>
> When 'array' goes out of scope close_values will be called, which will call __close on all the values in the array.
>
1. I mean using syntax
if local f,err=io.open ...
and for f,err=io.open ...

2. Even this case.How you suggest to fill this array in case of possible errors?