cps icon indicating copy to clipboard operation
cps copied to clipboard

support CPS transformations on nnkLambda and non-top-level procs

Open zevv opened this issue 4 years ago • 1 comments

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()  

zevv avatar Jul 24 '21 13:07 zevv

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.

disruptek avatar Aug 09 '21 03:08 disruptek