As per the tutorial manual
The void type is only valid for parameters and return types; other symbols cannot have the type void.
How can we declare a parameter in proc as void? Please provide a sample code.
Well the section already has examples. But maybe only what I write here is worth reading, so here it is:
The void type denotes the absense of any type. Parameters of type void are treated as non-existent, void as a return type means that the procedure does not return a value:
proc nothing(x, y: void): void =
echo "ha"
nothing() # writes "ha" to stdout
The void type is particularly useful for generic code:
proc callProc[T](p: proc (x: T), x: T) =
when T is void:
p()
else:
p(x)
proc intProc(x: int) = discard
proc emptyProc() = discard
callProc[int](intProc, 12)
callProc[void](emptyProc)
However, a void type cannot be inferred in generic code:
callProc(emptyProc)
# Error: type mismatch: got (proc ())
# but expected one of:
# callProc(p: proc (T), x: T)