A method for implementing a resumable function, the resumable function being a coroutine which returns a value upon completion, comprising: a compiler determining at compile time whether the resumable function has a lifespan that will not extend beyond a call to the resumable function made by a caller in a computing system, wherein the lifespan is a scope within which a given instance of the resumable function can exist; when the compiler determines that the resumable function lifespan will not extend beyond the call, the compiler generating code which upon execution will allocate an activation frame of the resumable function from a local stack memory of the caller in the computing system; and when the compiler determines that the resumable function lifespan can extend beyond the call, the compiler generating code which upon execution will allocate the activation frame from a heap memory in the computing system, wherein the method further comprises at least one of the following: the compiler generating code which upon execution in the target computing system verifies that a resumption address specified in the activation frame is a valid address before passing control based on that resumption address, the resumption address being the address of a resumable portion of a function body of the resumable function; the compiler generating code which upon execution in the target computing system verifies that a resumption index value specified in the activation frame is a valid value before passing control based on that resumption index value, the resumption index being an ordinal whose value distinguishes between a plurality of execution resumption points in a function body of the resumable function. a compiler determining at compile time whether the resumable function has a lifespan that will not extend beyond a call to the resumable function made by a caller in a computing system, wherein the lifespan is a scope within which a given instance of the resumable function can exist; when the compiler determines that the resumable function lifespan will not extend beyond the call, the compiler generating code which upon execution will allocate an activation frame of the resumable function from a local stack memory of the caller in the computing system; and when the compiler determines that the resumable function lifespan can extend beyond the call, the compiler generating code which upon execution will allocate the activation frame from a heap memory in the computing system, wherein the method further comprises at least one of the following: the compiler generating code which upon execution in the target computing system verifies that a resumption address specified in the activation frame is a valid address before passing control based on that resumption address, the resumption address being the address of a resumable portion of a function body of the resumable function; the compiler generating code which upon execution in the target computing system verifies that a resumption index value specified in the activation frame is a valid value before passing control based on that resumption index value, the resumption index being an ordinal whose value distinguishes between a plurality of execution resumption points in a function body of the resumable function. the compiler generating code which upon execution in the target computing system verifies that a resumption address specified in the activation frame is a valid address before passing control based on that resumption address, the resumption address being the address of a resumable portion of a function body of the resumable function; the compiler generating code which upon execution in the target computing system verifies that a resumption index value specified in the activation frame is a valid value before passing control based on that resumption index value, the resumption index being an ordinal whose value distinguishes between a plurality of execution resumption points in a function body of the resumable function.