If you run this program you will notice that even though there is an error in the function foo yet it’s not being pointed out by codea. But if you uncomment the second line and run the function without the coroutine codea will show an error.
Is this how it is supposed to be or a bug?
function setup()
--foo()
co = coroutine.create(foo)
coroutine.resume(co)
end
function draw()
coroutine.resume(co)
end
function foo()
for i = 1,1000 do
prin(ElapsedTime)
coroutine.yield()
end
end
@CodeaNoob, exactly, if you run that program it will not show an error even though it is supposed to.
@Jmv38 it’s not only print, even if I call a function which doesn’t exist it will not show an error. Basically anything that can cause an error will not cause one.
Like in this one.
function setup()
--foo()
co = coroutine.create(foo)
print(coroutine.status(co))
coroutine.resume(co)
end
function draw()
coroutine.resume(co)
print(coroutine.status(co))
end
function foo()
for i = 1,100 do
print(coroutine.status(co))
func()
coroutine.yield()
end
end
Is there a reason for just stopping the coroutine and not show errors?
I was using coroutines, and had not set the value of one of the variables and instead of showing any error it just stopped the coroutine. Took some to figure it out.
An issue(not exactly an issue) with lua would probably be the last thing in my mind. I thought its codea and not lua else would have checked google first.
I dont think that’s Codea or lua issue, a coroutine handle errors inside it’s ‘thread’, errors aren’t throwed outside. Try to print your coroutine resume :
function setup()
--foo()
co = coroutine.create(foo)
print(coroutine.resume(co))
end
function draw()
coroutine.resume(co)
end
function foo()
for i = 1,1000 do
prin(ElapsedTime)
coroutine.yield()
end
end