Write a macro to generate a call to `echo`.
Yeah that's what @lscrd meant about having to loop through with `stdout.write`,
if you want to duplicate `echo`'s behaviour
proc p1(args: varargs[string, `$`]) =
for a in args:
stdout.write(a)
stdout.write('\n')
proc p2(args: varargs[string, `$`]) =
p1(
Seems like `unpack_varargs` behaves not exactly as calling directly
import macros
proc p(args: varargs[string, `$`]) = unpack_varargs(echo, args)
p 1, 2, 3
echo 1, 2, 3
Run
Produces
["1", "2", "3"]
123
Run
I have never been able to make `varargs[typed, `$`]` work. I use `string`
instead of `typed`:
proc p(args: varargs[string, `$`]) =
echo args
Run
Unfortunately, `args` is displayed as an array and you have to loop on the
elements and use `stdout.write` to get wha
I hit exactly the same case, when I wanted to write wrapper p for echo, can you
guys please explain how to do that?
1) Why can't I use proc
proc p*(args: varargs[typed, `$`]) =
echo args
Run
2) Do I have to use the template here? (It compiles but still not work)