lua-users home
lua-l archive

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


> I'll leave this post with an idea...  How about merging John's "with"
> proposal and Roberto's "pcall-with-collectgarbage" proposal?  That is,
> have "with" handle cleanup on non-exceptional scope exit, and have
> pcall-with-collectgarbage handle cleanup on exceptional scope exit.

The main complains about my proposal is the cost of an exception. Adding
a "with" to the language will not solve that.

On the other hand, it is not difficult to add a "with" to the language
that works with exceptions. All we have to do is to use the upvalue
system. This system already has all that needs to control when a
variable goes out of scope. (This statement is not an endorsment to the
"with" proposal. I only want to point out that handling exceptional case
is not that difficult. Of course, that still leaves open the case where
a coroutines dies while keeping a resource.)

-- Roberto