Skip to content

Instantly share code, notes, and snippets.

@fowlmouth
Forked from def-/lc.nim
Last active August 29, 2015 14:12
Show Gist options
  • Save fowlmouth/09102ee53a95ebd2ec9a to your computer and use it in GitHub Desktop.
Save fowlmouth/09102ee53a95ebd2ec9a to your computer and use it in GitHub Desktop.
template ctime: expr =
var result: seq[int]
for a in 1..10:
for v in 1..10:
result.add a+v
result
const foo = ctime()
echo foo
## this should work
template ctimevalue(name,ty:expr, body:stmt): expr {.immediate.}=
template doit(): expr =
var name: ty
body
name
doit()
const foo = ctimevalue(result, seq[int]) do:
newseq result
for a in 1..10:
for b in 1..10:
result.add a+b
## or this
template ctimevalue(name,ty:expr, body:stmt): expr {.immediate.}=
template doit(): expr =
var name: ty
body
name
const x = doit()
x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment