Coroutine.isyieldable() doesn't work as expected

Hi there! I was trying to speed up my program with coroutine.yield(), and noticed a few weird things about how they work on the Simulator and device.

You obviously can't call yield() while the game is loading since there is no Lua coroutine running, but the problem is that the return value of coroutine.isyieldable() does not reflect this (because Lua is integrated into the kernel, it always returns true).

Also, another thing: It is implied (via the "C" icon in Inside Playdate) that the event handlers (AButtonDown etc.) are coroutines, but you can't yield from them either. The only built-in coroutine you seem to be able to yield from is playdate.update() or a function called by it.

The plot thickens -- after further testing, it seems coroutine.running() returns a coroutine (and false) even before the game has loaded, meaning the entire game is itself called by a coroutine.

This renders any attempt to detect whether yielding is allowed useless, as Lua will always say that it is even if the OS doesn't.

I've found a way to detect whether playdate.update() is in the stack trace. Since it can't be found by name, here's what I do:

local updateLine = string.format(":%d>", debug.getinfo(playdate.update).linedefined)
local isUpdate = debug.traceback():find(updateLine) ~= nil

It'd be nice if there were an easier way, but the only other way I could think of was iterating over each function in the call stack with debug.getinfo() until playdate.update() was found. Oh well.