That is a great and I'd say manual-worthy explanation.
var a = (proc(s: string))(doThing)
Run
Always wanted to know how to do this, thanks @eb
They're both a variation of metaprogramming, but their semantics are slightly
different. A template is code substitution that substitutes at every invocation
whereas a generic only generates a procedure once on it's first invocation.
proc doThing(a: auto) =
mixin otherThing
May I ask what are the differences in generics vs templates except for slightly
different syntax? I've tried to understand it from the Manual but to me it
seems that they have the same use-case. I've tried searching for some
discussion about this but couldn't find anything, perhaps it's clear to