Skip to content

Instantly share code, notes, and snippets.

@oprypin
Forked from PhilipWitte/gist:d1a382c8f21d10064fa2
Last active August 29, 2015 14:19
Show Gist options
  • Save oprypin/7e111f588177d763497e to your computer and use it in GitHub Desktop.
Save oprypin/7e111f588177d763497e to your computer and use it in GitHub Desktop.
import macros
macro doThis(s: static[string]): stmt =
let n = parseStmt(s)
quote do:
template actuallyDoIt: stmt =
`n`
template exec*(s: string) {.immediate.} =
doThis(s)
static:
actuallyDoIt()
exec("echo 1")
exec("echo 2")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment