lua-users home
lua-l archive

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


>> - yieldable pcall/metamethods

> Are for loop iterators yieldable?

Quick test shows that yes, they are. Hope that is official. :-)

$ ./lua
Lua 5.2.0 (work1)  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> f = function()for k, v in function() coroutine.yield() end, nil, nil do print("XXX") end end
> c = coroutine.create(f)
> assert(coroutine.resume(c))
> assert(coroutine.resume(c))

$ lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> f = function()for k, v in function() coroutine.yield() end, nil, nil do print("XXX") end end
> c = coroutine.create(f)
> assert(coroutine.resume(c))
stdin:1: attempt to yield across metamethod/C-call boundary
stack traceback:
	[C]: in function 'assert'
	stdin:1: in main chunk
	[C]: ?

Hurray!

Alexander.