Re: optional params before `untyped` body
with this PR [https://github.com/nim-lang/Nim/pull/11754](https://github.com/nim-lang/Nim/pull/11754) we can do it as follows: dispatch foo: for a in 0..<3: echo a echo 10 Run
Re: optional params before `untyped` body
Yeah, well... there is no good solution at the moment. Eventually overloading will work better and the "untyped params have all at the same position" restriction will be removed.
Re: optional params before `untyped` body
Especially given that overloading requires untyped parameters at the same position for all overloads.
Re: optional params before `untyped` body
I am so interested in knowing the answer to this one. Couldn't find a way to do that, had to use overloading. Works fine but feel like a hack rather than an idiomatic solution.
optional params before `untyped` body
Is there a way to have optional params before an untyped body in templates/macros? The last case gives an error, that's the one I want: template foo(a1 = 10, a2 = "", body: untyped) = discard # works foo(3, "asdf"): for a in 0..<3: echo a echo 10 foo(body = (echo 10)) # doesn't work: Error: type mismatch: got foo(): for a in 0..<3: echo a echo 10 Run The rule could be: allow optional typed parameters before an untyped statement list; it would be un-ambiguous. Workarounds are not great: * create a dummy type to group all optional params * create multiple overloads of the template