cps
cps copied to clipboard
support CPS transformations on nnkLambda and non-top-level procs
Could we support this?
let foo = proc() {.cps:C.} =
echo "foo"
foo()
And if possible, even this?
proc foo() {.cps:C.} =
proc bar() {.cps:C.} =
echo "bar"
bar()
foo()
and this
proc foo() {.cps:C.} =
let bar = proc() {.cps:C.} =
echo "bar"
bar()
foo()
let foo = proc() {.cps:C.} =
echo "foo"
foo()
I don't see how we can support this as long as the compiler rejects the following:
let foo =
type C = ref object of Continuation
proc(): C = echo "foo"
And unfortunately, unless we add an untyped pass, this means we cannot support the last example.
But the 2nd example, sure, we should be able to support that.