Thanks for that, looking forward to reading it. Curious to know your thoughts on the following. I made post this list some time ago claiming that the <close> mechanism could have been implemented with Lua's existing mechanisms like so:
| do
| local x<close> = CloseMe1()
| local y<close> = CloseMe2()
| print( x, y )
| return 5
| end
can be implemented as e.g.:
| return with( CloseMe1(), function( y )
| return with( CloseMe2(), function( x )
| print( x, y )
| return 5
| end)
| end)
where:
| function with(expr, func)
| ... = pcall(func, expr)
| getmetatable(expr).__close(expr)
| -- propagate errors and/or return result
| ...
| end
by copying the concept of "with" taken from Python. I understand that this wouldn't be equivalent to close completely, in that one could not take a suspended coroutine and call "close" on it to immediately close all to-be-closed variables on the stack. But, assuming that is not needed, would the above work for your use cases?
David