-
-
Save fowlmouth/aa06e723494708c8d21b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import macros, strutils | |
| macro unrolledLoop (name: expr, start, fin: int; body: stmt): stmt {.immediate.} = | |
| result = newStmtList() | |
| for x in start.intval .. fin.intval: | |
| var res = newStmtList() | |
| res.add parseStmt("const $1 = $2".format(name, x)) | |
| res.add body.copyNimTree | |
| result.add newBlockStmt(res) | |
| unrolledLoop(i, 0, 10): | |
| var x: array[0 .. i, char] | |
| echo i, ": ", sizeof(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment