lua-users home
lua-l archive

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




On 2019-06-23 5:07 p.m., Roberto Ierusalimschy wrote:
> Firstly, it had initially passed me by that <toclose> is only valid in
> single-variable local declarations. I'm curious what the rationale for
> this is, given the widespread use of multiple-return functions,
> including within 'toclose's primary usage example, io.open().

No specific rationale, it was just easier to implement. We will change
that.

-- Roberto


I do wonder how <toclose> handles nil, and why it's a bug for <toclose> to close a non-closeable value.

consider:

local <toclose> f, err = io.open(foo)
if not f then return nil, err end -- error: attempt to close non-closeable value