lua-users home
lua-l archive

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

on 6/12/04 6:37 AM, Luiz Henrique de Figueiredo at

> Of course, all this is simplified by the fact that C objects do not need to
> know about Lua objects. Like I said in the beginning, hybrid memory management
> is bound to be messy. (Perhaps this threadd is about the messy case and I've
> chattering away needlessly...)

This thread essentially is about the messy case. Lua's approach works well
for the simple case. Perhaps too well since it's that ease that makes it so
desirable to address the messy case. ;-)

There are a variety of goals that I'm aware of:

Foremost is the ability to have userdata objects reference Lua objects (and
other userdata objects) in a way that the Lua garbage collector can trace.

A secondary concern has been to have a way to keep the values private in the
same way that closures keep their values private.

Degree of concern over the second issue is probably lower than concern over
the first and should perhaps be dealt with in a general discussion of data
privacy. But that's just my opinion.

If you don't have privacy concerns, the second issue can be dealt with in a
moderately straightforward way though it might be nice to optimize pieces of
it. See my earlier message on hybrid objects. You can also achieve privacy
via per object metatables but that makes some other things like
type-checking messier.

Now, if one wants to get truly messy, try integrating the .NET memory
management with Lua memory management. Getting two independent garbage
collectors to work without either creating cycles or creating zombies --
i.e., hybrid objects that lose half their existence -- is difficult.