lua-users home
lua-l archive

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



On 06/10/2006, at 9:29 AM, Rici Lake wrote:

And for a good reason. If you remove the 'self' argument from the stack, and there is no other reference to it, then it could get garbage collected while your method is running, with possibly disastrous consequences.

I'm trying to think how this would actually be a problem.

I have taken the information from the self parameter and stored it (in my case a userdata field) and then removed it from the stack, so I don't want it any more. The called function doesn't want it, as it never gets it in the first place.

I suppose it could happen, if you called the function with a method that was anonymously created on-the-fly, but it seems a strange way to code to me.

In my case the item in question is a userdata that represents a (pointer to) an object that already exists, and will continue to exist even if the userdata is garbage-collected, but I suppose it depends on your application a bit.

- Nick