lua-users home
lua-l archive

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


On Sun, Jul 15, 2018 at 10:43 PM, Pierre Chapuis <catwell@archlinux.us> wrote:
I kind of agree that something like "with" could be useful in Lua. In my opinion one way to do it would be to have a construct which forces garbage collection of the variables created when exiting the block. This way cleanup would be left to the `__gc` metamethod, but it would be deterministic. The advantage would be that it would also work with code that already uses the `__gc` metamethod as a cleanup possibility.

Lack of an implementation strategy is not the obstacle to getting scope hook support into the Lua language.  There were plenty of proof-of-concept implementations 10 years ago.  (Using GC is not the preferred method, but that's besides the point.)

The challenge is convincing the Lua authors that this kind of feature is worth adding to the language.