Skip to content

--#noyield

With --#noyield you tell the compiler that a piece of code never yields. It changes nothing about the compiled code: it only stops the warnings about coroutines for that code.

Compiled functions can't yield (see Coroutines), so autoplay2c warns about every coroutine.yield it finds, and in AutoPlay Media Studio 9 and Setup Factory 10 about every function you give to coroutine.create or coroutine.wrap. When you know such code never yields, the warnings are noise. --#noyield silences them where you put it, and leaves them on everywhere else.

--#noyield
local co = coroutine.create(function(path)
    return File.DoesExist(path);  -- runs and returns, never yields: no warning
end);
local ok, exists = coroutine.resume(co, "C:\\data.txt");

Where It Applies

--#noyield applies to the statement that follows it, and everything inside it. On a function definition, that's the whole function, including the functions defined inside it:

--#noyield
function RunAll(tasks)
    for _, task in ipairs(tasks) do
        local co = coroutine.create(function() return task(); end); -- no warning
        coroutine.resume(co);
    end
end

These warnings are silenced:

Code Warning Silenced
A2C:IR:W:0110 coroutine.yield can't yield from compiled code Always
A2C:IR:W:0111 the function given to coroutine.create is compiled AutoPlay Media Studio 9 and Setup Factory 10 (Lua 5.3) only

Lua 5.1

In AutoPlay Media Studio 8 and Setup Factory 9.7, coroutine.create and coroutine.wrap only take Lua functions. A compiled function given to them raises Lua function expected, whether it yields or not. That warning stays, even with --#noyield: the code fails either way.

To silence a warning for the whole build instead of one statement, use --allow (see Silencing).

The Promise

Nothing in the statement yields. No coroutine.yield in it runs inside a coroutine, and no coroutine it creates yields, nor anything that coroutine calls.

When the promise is broken, your code behaves exactly as it would without the directive: the yield raises an error when it runs.

attempt to yield across a C-call boundary

The only difference is that autoplay2c didn't warn you about it.