[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Coroutines and protected calls
- From: "Albert-Jan Brouwer" <acj.brouwer@...>
- Date: Thu, 24 Oct 2002 17:01:15 +0200
It seems that pcall() is catching yields as well as errors
(see below). Is there some policy that must be adhered
to when mixing coroutines with the trowing and catching
of errors? E.g. never yield inside a Lua/C function that
can throw an error that must be catchable?
-----
function co1 ()
for i=1,4,1 do
print(i)
coroutine.yield()
end
end
function co2 ()
for i=1,4,1 do
print(i)
pcall(coroutine.yield)
end
end
c1 = coroutine.create(co1)
c2 = coroutine.create(co2)
-----
< c1()
> 1
< c2()
> 1
> 2
> 3
> 4