lua-users home
lua-l archive

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

On 16.02.2010 17:56, Valerio Schiavoni wrote:
> Hello everyone,
> can anyone explain me what's happening running this simple lua script:
> --metaerror.lua
> coroutine.create(coroutine.yield())

This example is not valid, so the behaviour is undefined.
"Creates a new coroutine, with body f. f must be a Lua function."
Try this instead:
coroutine.create(function() coroutine.yield() end)

> I've searched on google for that error, but many references belong to
> the interaction between C++ and Lua code. Here it's only Lua.
> I agree that that kind of code is not really very useful..but I'd like
> to understand it.

The function expects the argument as a lua function, and you give it a C
function (check it out with debug.getinfo()).