[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Calling C++ class methods from Lua (newbie)
- From: Rici Lake <lua@...>
- Date: Sun, 16 Oct 2005 01:30:16 -0500
On 15-Oct-05, at 5:51 PM, David Given wrote:
...actually, a thought: if I were to run Lua in an environment managed
*real* garbage collector, lik the Boehm libgc, would it be worth my
disable Lua's own garbage collector? If so, how?
That's an interesting question.
First of all, if I had written Lua's garbage collector, I would have
offence to your use of *real*. The Lua GC is a real garbage collector,
quite a reasonable one. It suffers from not being integrated with a
allocator, perhaps, but the consequence is that it is fully portable.
Nonetheless, one might wish to integrate Lua's memory management with
memory management available in some external environment. This will
to be tricky, because the Lua data structures used to support its
collection are also used for other purposes. So it would be necessary
disentangle some of the linked lists.
Beyond that, the Lua garbage collector performs some tasks which are
specific to Lua's semantics. For example, the Boehm garbage collector
not really have any mechanism equivalent to Lua's weak tables, or even
mechanism which could easily be used to implement weak tables. And,
the Boehm collector can implement finalization, it does not do so in a
consistent with Lua's (arguably idiosyncratic) semantics, which could,
theory, be used to change, add or delete __gc metamethods during the
span of an object, something not normally contemplated by finalization
That's not to say that it couldn't be done, of course.