lua-users home
lua-l archive

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


> 1) Is it possible to call a function in lua and pass in a reference to
> an object and set that object to nil like above?
	No.  You'll have to give its name too so the function could
assign nil to the variable with that name.  Not a good solution...

> 2) Is it possible to make MyObject = nil from C, I have tried setting
> MyObject to nill using pushnil etc and removing all references in tables
> to this object but it still remains in lua..
	You could search for all variables that store references
to that table and change them, but this is a very cost solution.

	Another way is to save a name within the object (instead
of "MyObject = {}" you should create a new object with
"NewObject('MyObject')") so that the destructor could assign "nil"
to that name.  However this does not "destruct" another reference
to the same object:

NewObject('MyObject')   -- variable MyObject is created!
-- do something with variable MyObject
otherObject = MyObject
MyObject:Destroy()
-- MyObject == nil, but otherObject still refers to the object!

	Tomas