lua-users home
lua-l archive

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


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