I use dirty templates a lot but only when I need to capture 5~10 variables in
the environment.
It's very easy to refactor and forget that the dirty template was capturing
something, it happen to me with result. In your case the transformation is easy:
proc Core_Not*[F,X,V](f: F, xl: X): V {.inline.} =
let v0 = f.validateOne(xl.list[0],[BV,IV])
case v0.kind
of BV:
if v0.b: result = TRUE
else: result = FALSE
of IV:
result = valueFromInteger(bitnot(v0.i))
else: discard
Run
to
template Core_Not*[F,X,V](f: F, xl: X): V =
let v0 = f.validateOne(xl.list[0],[BV,IV])
var tresult: V
case v0.kind
of BV:
if v0.b: tresult = TRUE
else: tresult = FALSE
of IV:
result = valueFromInteger(bitnot(v0.i))
else: discard
tresult
Run