lua-users home
lua-l archive

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


On Sunday 21 August 2005 01:00, Brent Arias wrote:
> For example, if I simply set the
> coroutine variable to nil, will Lua understand to kill the coroutine
> (regardless if it is yielded or not) and clean up its stack, all in a
> graceful fashion?

I would have thought so. Once the last reference to the coroutine is lost, the 
entire thing will be garbage collected; code, stack, locals, the lot.

Incidentally, you can *only* do this, with someone else's coroutine if you're 
running --- if it hasn't yielded, then *it* must be running! Remember that 
coroutines aren't threads.

I am curious to know what happens if a coroutine nils out its own last 
reference, though. Does the program counter carry an implicit reference to 
the code its executing? What happens when the coroutine yields?

-- 
"Curses! Foiled by the chilled dairy treats of righteousness!" --- Earthworm 
Jim (evil)

Attachment: pgpglijkcl9qp.pgp
Description: PGP signature