maxtaco/coffee-script — Issue #18: deferred argument cannot be passed to another asynchronous function
Author: andybisson
Created: 2012-02-22 12:59:27+00:00
State: open

I may have misunderstood the purpose of await and defer but I understood it to implement delimited continuations.
This is not how it seems to work in practice. The intended operation of the following code under node.js should be reasonably clear. The continuation is passed to process.nextTick to be called later. What actually happens is that cont is called with undefined as its argument when control leaves testContinuation.
I have since noticed in this forum that nested awaits and multiple calls to these 'continuations' don't work either so I presume I have misunderstood the intention.

If this is the case, is there any reason that the full CPS transform has not been implemented?

```coffeescript
class Test
constructor: ->

testContinuation: ->
await
@getContinuation defer val
console.log "val = #{val}"

getContinuation: (cont) -> process.nextTick -> cont "hello"

(new Test).testContinuation()
```