Macro beginner code review

2021-02-05 Thread Psirus
Yes, `cfunc` is in reality a C function from an external library that I want to wrap that does something completely different.

Macro beginner code review

2021-02-05 Thread PMunch
I think his `cfunc` there was just a dummy to test with, not what he actually wanted to do. But otherwise it would be possible to do it like you do.

Macro beginner code review

2021-02-05 Thread Arrrrrx2
As a practice is good, but you can even use templates: template wrapper(arg: varargs[untyped]): string = var h, t = "" for f in fields((arg)): when f is string: (h &= "s";t &= f;) elif f is int:(h &= "i"; t &= $f;) (h & t) # "tests"

Macro beginner code review

2021-02-04 Thread ElegantBeef
I second this, `quote` is just one tool, not something you need to or have to use.

Macro beginner code review

2021-02-04 Thread xigoi
This looks good! I'm pretty sure using `quote` wouldn't really improve it.

Macro beginner code review

2021-02-04 Thread Psirus
So I'm trying to learn macros, and its not easy if you've never done metaprogramming. Anyway, I'm trying to write a wrapper for a C function that takes a variable number of arguments, with the first being a string that specifies the types of the rest. I want the wrapper to create this string au