diff options
author | Araq <rumpf_a@web.de> | 2012-08-30 22:55:32 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-08-30 22:55:32 +0200 |
commit | 1d14cb1ad8d4d98ea19daa2d5ab6ded59d58553a (patch) | |
tree | c32929ff723358f440415d7610fd283f58f17a91 /tests/run | |
parent | 1786e3099141f6548e9f6cd4f4998d32f602b71d (diff) | |
download | Nim-1d14cb1ad8d4d98ea19daa2d5ab6ded59d58553a.tar.gz |
next steps towards term rewriting macros; simple examples work
Diffstat (limited to 'tests/run')
-rw-r--r-- | tests/run/tpatterns.nim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/run/tpatterns.nim b/tests/run/tpatterns.nim new file mode 100644 index 000000000..4a83d167c --- /dev/null +++ b/tests/run/tpatterns.nim @@ -0,0 +1,17 @@ +discard """ + output: '''48 +hel''' +""" + +template optZero{x+x}(x: int): int = x*3 +template andthen{x*3}(x: int): int = x*4 +template optSubstr1{x = substr(x, a, b)}(x: string, a, b: int) = setlen(x, b+1) + +var y = 12 +echo y+y + +var s: array[0..2, string] +s[0] = "hello" +s[0] = substr(s[0], 0, 2) + +echo s[0] |