1 2 3 4 5 6 7 8 9 10 11
discard """ output: '''-2''' """ 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)