Hello world. Please, what is wrong with my code ?
var
i1 = 1
i2 = 2
i3 = 3
proc show(i: var int) = echo i # A proc that needs var
proc myProc(ii: var varargs[int]) =
for i in mitems ii:
show i
myProc(i1, i2, i3);
With varargs[var int], I get:
Error: invalid type: 'var int' in this context: 'proc (ii: varargs[var int])' for proc
Well view types should allow it to happen, but until then you can either do the open array or use a macro like:
import std/macros
macro myPretendProc(ii: varargs[var int]): untyped =
result = newStmtList()
for x in ii:
result.add newCall("show", x)
var
i1 = 1
i2 = 2
i3 = 3
proc show(i: var int) = echo i # A proc that needs var
myPretendProc(i1, i2, i3);