I have a situation similar to the following:
template subBlock():untyped {.dirty.} =
#echo elems.len
const
b = elems.len
template register(a:int):untyped {.dirty.} =
elems.add(a)
template mainTemplate(body:untyped):untyped {.dirty.} =
var
elems:seq[int]
body
mainTemplate:
register(4)
register(5)
subBlock()
I am calling a template named register a number of times (in this example two times). In the template subBlock, it fails saying that elems cannot be evaluated at compile time.
I need b to be a const.
Any workaround?
You people are amazing. Now I have to understand the magic and integrate it.
Thanks a lot.