Garbage collection fallback....

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Garbage collection fallback....

Bret Mogilefsky

The documentation says that the "gc" callback is called during garbage
collection, and that it receives the table being collected as an
argument.  First, is the argument ALWAYS a table?  What about strings?
And does Lua garbage collect things of type LUA_T_USERDATA?  For
example, let's say I have a type defined with:

	typedef enum {
	} tNewLuaTypes

What happens if the user does something like:

	local vector

	vector = Vector(2.0, 2.0, 2.0)   -- Vector returns userdata with tag
	vector = nil

...or if I have an arith fallback that does vector negation, what do I
do when the user does...

	local vector1, vector2
	vector1 = Vector(2.0, 2.0, 2.0)
	vector2 = -vector1
	vector2 = nil

...?  Do I allocate a vector during the fallback?

Thanks in advance,


"Why, that's the second biggest monkey head I've ever seen!" --Guybrush
"LeChuck's dead. I blew him into a million gooey pieces."    --Guybrush
Bret Mogilefsky   **   [hidden email]   **   Programmer, LucasArts