Oh yes, I could have made that more clear.
Indeed, the default type is untyped. Both for the arguments as well as the
return type.
And yes, untyped is required to make this work. Essentially untyped is just
considered as a raw Nim identifier (nnkIdent in macro terms). If you used
string as an
Does that work because the default type for a template argument is `untyped`? I
saw another post recently that said `prefix: string` doesn't work, `prefix:
untyped` is required.
Brilliant. Thanks a lot.
How can I create a new function with a template so that the created function
has its function name prefixed? Something like:
template mytempl(prefix) =
proc $prefix & World() = echo "hello world"
Run
So that:
mytempl(hello)
Run
creates a
You do it like this:
template mytempl(prefix) =
proc `prefix World`() = echo "hello world"
Run
See here:
[https://nim-lang.github.io/Nim/manual.html#templates-identifier-construction](https://nim-lang.github.io/Nim/manual.html#templates-identifier-construction)