[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: resuming a into dofile
- From: Mike Pall <mikelu-0707@...>
- Date: Fri, 20 Jul 2007 13:45:34 +0200
Hi,
Arithmeth wrote:
> I am trying to do the following: create a coroutine, run a dofile inside it,
> yielding from the file called with dofile, then resuming again the
> coroutine.
This doesn't work since dofile() is a library function written in
C and you cannot yield across a C call boundary (search the
archives for lots of explanations about this).
But you can just replace
dofile(name)
with:
assert(loadfile(name))()
That's a plain call in the 2nd case, so you can yield from inside
the second file.
> coroutine.resume (cof)
You should really check the result of coroutine.resume(), e.g.:
assert(coroutine.resume(cof))
Then you would have noticed the error:
"attempt to yield across metamethod/C-call boundary"
Bye,
Mike