Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Slight updates to docs, but I need to run out for the day.

  • Loading branch information...
commit 6f2d96eafd182fcb4aae12fca293c32ac476d903 1 parent b857c00
@maxtaco authored
Showing with 9 additions and 16 deletions.
  1. +9 −16
@@ -277,28 +277,21 @@ assignment of multiple values at once, accessed as an array.
These specifics are also detailed in the code in the `Defer` class,
file ``.
-### Why Can't `await` Blocks Act Like Expressions?
+### Awaits Can work as Expressions
-It might be possible, with an insane amount of hoop-jumping, to make
-something like this work:
+*In a rush*
-x = await myfunc defer _
+An `await` block takes the value of its first `defer'ed slot.
-And have the value of the right hand side evaluate to whatever the
-value `_` gets when `myfunc` fulfills its deferral. That _might_ be
-possible, but something like this seems even uglier to implement:
+add = (a,b,cb) ->
+ await setTimeout defer(), 10
+ cb(a+b)
-yourfunc (await myfunc defer _), (await otherfunc defer _)
+x = (await add 3, 4, defer()) + (await add 1, 2, defer())
+console.log "#{x} == 10"
-It would be a significant additional implementation challenge to get
-`await` statements working like expressions everywhere.
-It's not worth, in our opinion, a lot of added complexity
-to get a half-baked solution.
## Translation Technique
The CoffeeScript tame addition uses a similar continuation-passing translation

0 comments on commit 6f2d96e

Please sign in to comment.
Something went wrong with that request. Please try again.