Quirrel4.41.0

types.Generator.getstatus

Method on every generator
generator.getstatus(): any

Returns the generator's current state as a string.

Return value

One of:

Notes

A freshly created generator - before its first resume - already reports "suspended", the same as one paused mid-body; there is no separate "not started yet" state.

"dead" is permanent: resume on a dead generator throws resuming dead generator rather than restarting the body. Compare types.Thread.getstatus, whose thread goes back to "idle" instead and can be started again with call.

Example

examples/types/generator/getstatus.nut
function geny() { yield 1; return null }
let g = geny()
println("g.getstatus() =", g.getstatus())   // suspended before the first resume too
println("resume g =", resume g)
println("g.getstatus() =", g.getstatus())
println("resume g =", resume g)
println("g.getstatus() =", g.getstatus())
try { resume g } catch(e) { println("resume g throws:", e) }
Output:
g.getstatus() = suspended
resume g = 1
g.getstatus() = suspended
resume g = null
g.getstatus() = dead
resume g throws: resuming dead generator

See also

weakrefReturns a weak reference to the generator.
getstatusReturns the thread's current state as a string.
generatorclass index