Last active
June 19, 2016 18:16
-
-
Save Varriount/94eb49206bd6268e48d042b4c1f63108 to your computer and use it in GitHub Desktop.
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
import asyncdispatch | |
# See http://nim-lang.org/docs/manual.html#templates-typed-vs-untyped-parameters | |
# for information on typed vs untyped parameters | |
template doAsync(name, body: untyped): untyped = | |
# Backticks allow us to use an expression or statement as an identifier | |
proc `name`() {.async.} = | |
body | |
asyncCheck(`name`()) | |
template doAsync(body: untyped): untyped = | |
proc asyncproc() {.async.} = | |
body | |
asyncCheck(asyncproc()) | |
# The 'do' notation allows passing in a block of code to the last parameter in a | |
# template or macro. | |
doAsync do: | |
echo "hello" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment