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 <void>
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