documented AST overloading and some TR optimizations

This commit is contained in:
Araq 2012-12-09 03:02:52 +01:00
commit 92f8f2e776
6 changed files with 109 additions and 10 deletions

View file

@ -0,0 +1,11 @@
discard """
output: '''-1'''
"""
proc p(x, y: int; cond: bool): int =
result = if cond: x + y else: x - y
template optP{p(x, y, true)}(x, y: expr): expr = x - y
template optP{p(x, y, false)}(x, y: expr): expr = x + y
echo p(2, 4, true)