[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.2: environment table and coroutine
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 2 Apr 2010 17:51:38 -0300
> I read several articles about lua 5.2, but confused about environment
> tables. some says lua functions don't have environment tables any more, but
> in the document of lua 5.2-work1/2, it says there is no global tables but
> environment tables.
The new proposal for environments (based on _ENV) came after the release
of work2.
> so, what kind of environment table is there? I also
> found a new introducing function, loadin. my concern is where are the
> entries provding to loadin? in the envrionment table or the global table?
> what's the scope of those entries? can these variables be a closure?
I did not undestand these questions.
> Also, i have some questions about the coroutines. because i will create and
> dispose lots of coroutines, i have to implement a coroutines pool to
> optimize this payload. it works fine when a coroutine ends normally, not
> yielded, no errors. so I can recycle it into my pool. but when the coroutine
> yields or errors, lua seemed saves the status and the stack of the
> coroutine, and I didn't find a way to reset the coroutine to the initial
> state, where I can put a new function to run. in this case, i have to
> dispose the coroutine rather reuse in my pool. it still works fine now since
> so far i don't need to terminate a yielding thread, but I guess this would
> happen in some time... so I was wondering if there is a way to reset a
> coroutine to the initial state, in 5.1 or any new functions will be
> introduced to 5.2?
Why can not you simply allow those coroutines to be collected and create
new ones?
-- Roberto