Re: Template - how to prefix a function's name

2020-04-02 Thread Vindaar
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

Re: Template - how to prefix a function's name

2020-04-01 Thread cdunn2001
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.

Re: Template - how to prefix a function's name

2020-03-24 Thread mantielero
Brilliant. Thanks a lot.

Template - how to prefix a function's name

2020-03-24 Thread mantielero
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

Re: Template - how to prefix a function's name

2020-03-24 Thread Vindaar
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)