[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: gc problem when using lightuserdata to reference C++ objects
- From: Florian Weimer <fw@...>
- Date: Fri, 14 Nov 2008 15:22:00 +0100
* 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).