Skip to content

Instantly share code, notes, and snippets.

@zah
Created June 14, 2019 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zah/ce81db77fdd9fd204ad46409bcba6617 to your computer and use it in GitHub Desktop.
Save zah/ce81db77fdd9fd204ad46409bcba6617 to your computer and use it in GitHub Desktop.
import macros
template generateCode(body: untyped) =
iterator yields: NimNode = body
macro payload: untyped =
result = newStmtList()
for node in yields():
result.add node
payload()
generateCode:
yield quote do:
echo "hello"
yield quote do:
echo "world"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment