Great thoughtful question. I second the general usage of `block` above. I also
wanted to add that defining templates inside a proc can be useful for
legibility as well without needing to define arguments and/or types to a proc.
It can be nice to reduce code de-duplication too. Something like this:
proc computeSomething(nodes: seq[SomeNode]) =
template columns(n: untyped): untyped = n.someItem.field.columns
for i, node in nodes:
doSomething(node.columns[I])
doSomethingElse(node.columns[I])
...
Run