Skip to content

Instantly share code, notes, and snippets.

@zah
Created August 29, 2011 19:03
Show Gist options
  • Save zah/1179131 to your computer and use it in GitHub Desktop.
Save zah/1179131 to your computer and use it in GitHub Desktop.
template repeatStmt(N: int, code: stmt) : stmt =
when N > 0:
code
repeatStmt(N-1, code)
template repeatTemplate(N: int, tmpl: expr) : stmt =
when > 0:
tmpl(N)
repeatTemplate(N-1, tmpl)
template createOverload(N: int) =
# magically create overload here for tuple with 3 fields
repeatTemplate(10, createOverload)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment