lua-users home
lua-l archive

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


> Lua already does that when closing upvalues, in luaF_close. This
> proposal would probably be implemented by expanding luaF_close's
> purpose to also call the __close metamethod on these new types of
> locals. Fortunately a lot of the work for closing upvalues overlaps
> here.

Exactly. A "local <new name>" will create an upvalue just like a closure,
but with an extra bit telling "I need finalization". Then, luaF_close
checks that bit when closing upvalues and call the appropriate functions
when needed. (The implementation would be trivial; what makes things
more complex is handling errors inside those functions.)

-- Roberto