|
Having a close() method may be a good idea for many uses of userdata, where freeing resources referred by the userdata can be independent of the userdata lifetime. In such cases, it makes sense to test against NULL for the userdata contents, etc. Calling udata:close() won't set the udata to nil, won't free the userdata itself, since this is under the control of the garbage collector. But this is irrelevant to __gc. The __gc metamethod, as far as I understand, is supposed to be a kind of callback into C to let you know that the userdata has been collected, so you can free additional resources if necessary. It makes no sense to expose this method to Lua code. Using __gc as a close() method confuses two distinct purposes. On Mar 30, 2007, at 6:01 PM, Javier Guerra wrote:
grrr waaa www.grahamwakefield.net |