lua-users home
lua-l archive

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


(with lua 5.0)

I'm baffled by a

  attempt to yield across metamethod/C-call boundary

error I'm getting. I'm not yielding across a C call, as best I can tell.

I have a C runtime that does a lua_getglobal("dipatch"), and calls
dispatch() with events. In lua, I do

	function main(msg)
	    print(msg)
		for msg in wait do
			print(msg)
		end
	end

	local _main=coroutine.wrap(main)
	function wait()
		return coroutine.yield()  -- <--- this is "attempt to yield across metamethod/C-call boundary"
	end
	function dispatch(msg)
		_main(msg)
	end

What is stranger, is that rewriting main() can remove the error, and run
fine, but I don't understand why:

  function main(msg)
	   print(msg)
  	msg = wait()
    print(msg)
  	msg = wait()
    print(msg)
  end


Whats going on? Any ideas?

Cheers,
Sam