-
-
Save fowlmouth/09102ee53a95ebd2ec9a 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
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