lua-users home
lua-l archive

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


Hi...

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 {
		MY_T_TYPE1 = LUA_T_USERDATA + 1,
		MY_T_VECTOR,
		MY_T_TYPE3	
	} tNewLuaTypes

What happens if the user does something like:

	[...]
	local vector

	vector = Vector(2.0, 2.0, 2.0)   -- Vector returns userdata with tag
MY_T_VECTOR
	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,

Bret

--
"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   **   mogul@lucasarts.com   **   Programmer, LucasArts