[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: dofile, loadfile, loadstring in a coroutine + token filter
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 23 Apr 2007 10:18:41 -0300
> the token filter must be reset before every loadstring, loadfile or
> dofile call. I'm trying to figure out why - the coroutines never
> return so they should always be resumable.
It's because the lex state is saved as an upvalue of the raw get token
function that is passed to the token filter. So, although the coroutine
hasn't returned, it is still using an old lex state. I'm sorry, the docs
and the code should be more explicit about this. One simple way to handle
this is to set FILTER to nil when <eof> is seen.