On Nov 30, 2019, at 2:08 PM, minf...@arcor.de wrote:
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/e36eb032-ffbc-4b26-8c41-f76aa6dcdd00%40googlegroups.com.
Make the type interface{} and you can pass anything and use reflectOn Nov 30, 2019, at 2:08 PM, minf...@arcor.de wrote:
--C allows comma-separated argument lists via variadic macros. Whereas AFAIK golang allows only variadic arguments of the same type.(Please excuse if I am wrong, I am considering myself a golang newbie)C demo program that prints: -- -- 1 and 1 1 and 1// ###### C variadic macro test
#include <stdio.h>
#define PR(...) if(df){printf(__VA_ARGS__);\
if(ef)fprintf(stderr,__VA_ARGS__);}
// Flags
int df=1, ef=1;
int main(void) {
PR("-- ");
PR("%d and %d ",df,ef);
}// ###### EndHow would one implement an equivalent PR(...) "function" in Go ???
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/181a2df8-f5a2-4a35-9d34-6645d2b1356a%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/e36eb032-ffbc-4b26-8c41-f76aa6dcdd00%40googlegroups.com.
func PR(f string, a ...interface{}) {if d { return }fmt.Fprintf(os.Stderr, f, a...)}Add appropriate imports.
On Nov 30, 2019, at 12:08 PM, minf...@arcor.de wrote:
C allows comma-separated argument lists via variadic macros. Whereas AFAIK golang allows only variadic arguments of the same type.(Please excuse if I am wrong, I am considering myself a golang newbie)C demo program that prints: -- -- 1 and 1 1 and 1// ###### C variadic macro test
#include <stdio.h>
#define PR(...) if(df){printf(__VA_ARGS__);\
if(ef)fprintf(stderr,__VA_ARGS__);}
// Flags
int df=1, ef=1;
int main(void) {
PR("-- ");
PR("%d and %d ",df,ef);
}// ###### EndHow would one implement an equivalent PR(...) "function" in Go ???--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.