Created
November 5, 2013 16:05
-
-
Save Artazor/7321358 to your computer and use it in GitHub Desktop.
Any chances to make such syntax/semantics consistent? Can we allow multiple unwinds
1) per defer
2) dynamically per await (eg in await for-loops)
3) statically per await
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
someFunc = (x,y,z, cb) -> | |
await check x, defer err, res_x | |
return cb err if err | |
await check x, defer err, res_y | |
return cb err if err | |
await check x, defer err, res_z | |
return cb err if err | |
cb null, res_x + res_y + res_z | |
# PROPOSAL: "unwinding defers" | |
# use | |
# | |
# await f defer cb(err), res | |
# | |
# as short syntax for | |
# | |
# await f defer err, res | |
# return cb err if err | |
# | |
someFunc2 = (x,y,z, cb) -> | |
await check x, defer cb(err), res_x | |
await check x, defer cb(err), res_y | |
await check x, defer cb(err), res_z | |
cb null, res_x + res_y + res_z | |
Thanks a lot! Just what I needed!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's the way I deal with this. Cheers.