further improvements for term rewriting macros
This commit is contained in:
parent
b4cd119800
commit
6753d36854
8 changed files with 74 additions and 28 deletions
19
tests/patterns/tstar.nim
Normal file
19
tests/patterns/tstar.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
discard """
|
||||
output: "my awesome concat"
|
||||
"""
|
||||
|
||||
var
|
||||
calls = 0
|
||||
|
||||
proc `&&`(s: varargs[string]): string =
|
||||
result = s[0]
|
||||
for i in 1..len(s)-1: result.add s[i]
|
||||
inc calls
|
||||
|
||||
template optConc{ `&&` * a }(a: expr): expr = &&a
|
||||
|
||||
let space = " "
|
||||
echo "my" && (space & "awe" && "some " ) && "concat"
|
||||
|
||||
# check that it's been properly optimized:
|
||||
doAssert calls == 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue