lua-users home
lua-l archive

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


The main safety concern would not be necessary if __gc was only visible to the C API, not Lua.  

In my app I must necessarily be concerned with performance; and I also follow the common example of having the metatable equal the method table for this reason.

On Mar 30, 2007, at 12:31 PM, Rici Lake wrote:

Michael Broughton wrote:
You suggest that it is not a good idea to combine the metatable and method table for userdata. Is performance the only reason?
Sorry if I have been confusing terminology in my emails. I always combine the metatable and method table in my libraries. The third party Lua libraries I've looked at do this as well. So do the examples in PIL2.

Yes, I know it's common.

My distaste for it comes more from a desire for writing safe modules
than performance considerations. I think this thread demonstrates the
safety issues involved in conflating the two tables. However, once
you decide (if you do) to separate the metamethod and method tables,
you are certainly free to take advantage of resulting efficiencies :)

Fortunately, Lua is flexible enough to encompass both solutions, and
a variety of other ones.



grrr waaa
www.grahamwakefield.net