lua-users home
lua-l archive

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

* Javier Guerra Giraldez:

> in short, just add a 'close' method to the Lua object, and call it
> as soon as you don't need it.

Is there a short idiom to express this sort of resource management in
the presence of exceptions?

For instance, it would be handy if you could write:

   temporary large_object = lobj.allocate()

(instead of "local large_object") and Lua called large_object's
__dispose meta-method if the scope of large_object is left (either
through a normal return, or through an exception; as a side effect,
this turns tail calls into normal calls).