I made post this list some time ago claiming that the <close> mechanism could have been implemented with Lua's existing mechanisms like so:
| function with(expr, func)
| ... = pcall(func, expr)
| -- propagate errors and/or return result
I must admit, having this topic raised was the last thing I expected ;)
I'm well versed in trying to use Lua function lambdas for this kind of problem. The result is not satisfying.
The problem with lambdas masquerading as code blocks is that the natural control structures of the language become unusable, or very confusing. Think about what `return` and `break` mean in the context of a lambda vs. a real code block. Preserving the intended use of basic control structures is essential for keeping code manageable.
Sure, you could write any Lua program as a single block of code and only `goto` (giving up functions, `while` loops, etc.), but that sounds like 1960's assembly language, not Lua. The goal was to support scope hooks while preserving all that Lua is.