lua-users home
lua-l archive

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




2014-11-18 16:04 GMT-08:00 arioch82 <arioch82@gmail.com>:
if that's the case and i create and run multiple coroutines on the same
non-anonymous function how would all variables local to the function behave?
they would all resume each other and share the same data?
that would also mean that all locally created userdata/tables will never be
free since there will always be a variable in the module pointing to that
function


--
View this message in context: http://lua.2524044.n2.nabble.com/coroutines-local-userdata-and-GC-tp7664107p7664135.html
Sent from the Lua-l mailing list archive at Nabble.com.



Local variables do not belong to a function (or closure, strictly speaking). Instead, they reside on stack therefore they belong to one "invocation" to a function. When two coroutine share the same function, each still maintain a separated stack of that function. So the two share the same set of upvals but have separated local vars.