如 f1 ( callback: f2(callback: f3) )
写成
f1()
f2()
f3()
写成
f1()
f2()
f3()
1
hooluupog Apr 18, 2015 支持async/await的语言(c#,dart,es7)或者goroutine+chanel都可以。
|
2
sumhat Apr 18, 2015 via iPhone JS 中的 Promise 也可以
|
3
Monad Apr 18, 2015 Coroutine就是拿来干这个的嘛…
C/C++用makecontext/swapcontext, lua原生支持coroutine |
6
mucid Apr 18, 2015 python3
yield from |
7
coolicer Apr 18, 2015 node的async库 ,隐
|
8
bombless Apr 18, 2015 CPS嘛……
其实加一个能处理 AST 的预处理期就好了,这个任何通用语言都能做。 又或者让代码通过源代码解释执行,或者热加载代码。这些都不需要语言来支持,语言只需要能回调、支持 FFI,剩下的有平台支持就够了。 在带有语法插件/Lisp宏的语言中会更方便。 |
9
phoenixlzx Apr 18, 2015 promise/async 都比 yield 好用...
yield 那货比 callback 还反人类... |
10
h4x3rotab Apr 18, 2015
C# async
|
11
billzhuang Apr 18, 2015
所有语言的promise
|
12
newtonisaac Apr 18, 2015
@billzhuang yes
|
13
JamesRuan Apr 18, 2015
do syntax sugar for Haskell Monad
|
14
binux Apr 18, 2015 via Android yield 可以在同一个作用域中干活,省去了参数传递
|
15
clino Apr 18, 2015
gevent AsyncResult
|
16
ffffwh Apr 18, 2015
call/cc
|
17
plantain Apr 19, 2015
C++17 await
|
18
bolasblack Apr 19, 2015
试试这个? https://github.com/tj/co
|
19
futursolo Apr 19, 2015
Node.js: Promise
Python(Tornado based Application): Future(Use with yield) Go: goroutine |
20
quix Apr 19, 2015
还有一种思路,用future对象, 可以看下ruby的celluloid
|
21
hitsmaxft Apr 19, 2015 via iPhone
java都行啦,killim在字节码层做下cps变换就行了。
|