bugfixes and improvements for term rewriting macros

This commit is contained in:
Araq 2012-09-04 23:57:39 +02:00
commit 30c00aba07
5 changed files with 30 additions and 19 deletions

View file

@ -15,5 +15,5 @@ template optConc{ `&&` * a }(a: expr): expr = &&a
let space = " "
echo "my" && (space & "awe" && "some " ) && "concat"
# check that it's been properly optimized:
# check that it's been optimized properly:
doAssert calls == 1

View file

@ -5,14 +5,14 @@ discard """
"""
template optWrite{
write(stdout, x)
write(stdout, y)
}(x, y: string) =
write(stdout, "|", x, y, "|")
write(f, x)
((write|writeln){w})(f, y)
}(x, y: varargs[expr], f, w: expr) =
w(f, "|", x, y, "|")
if true:
echo "0"
write stdout, "1"
write stdout, "2"
writeln stdout, "2"
write stdout, "3"
echo "4"