4 ms·
+1. ! is the worst part of Rust macros. There is just a terrible mismatch between the use-case macros were originally intended for (embedding different languag
by frowaway001 12y ago
+1. ! is the worst part of Rust macros.
There is just a terrible mismatch between the use-case macros were originally intended for (embedding different languages) and how they are mainly used now (emulating varargs).
The current arguments from Rust people are mainly defensive in that area, but maybe they will revisit this as the community matures.
- kibwen 12y ago> There is just a terrible mismatch between the use-case > macros were originally intended for (embedding > different languages) and how they are mainly used now > (emulating varargs). This is incorrect. I can't think of any macros that are used to paper over the lack varargs (`println!` certainly doesn't count, because even if Rust had varargs you'd still need a macro here to do typesafe compile-time string parsing). In any case, varargs can already be trivially emulated using vectors (which afaict is essentially what Go does, but Go has sugar for it). Macros would be overkill for this use case.
- frowaway001 12y ago> This is incorrect. Eh ... did you have a look at the "standard" library? > `println!` certainly doesn't count, because even if Rust > had varargs you'd still need a macro here to do typesafe > compile-time string parsing Yeah, but you could do it without exposing all the horrible mess to users. The usual "OMG!!! Look at that random `!`. Stand back, I'm using a macro here and would like to warn you that semantics will be totally different!!!"-dance is just embarrassing, especially given the fact that you can design printf-like functionality without needing varargs in the first place. With or without macros, if your API requires warning signs it just sucks, and you should fix it instead of using "hey, but I warned people!" as an excuse. > varargs can already be trivially emulated using vectors Oh right! So how do we create a vector? vec![1, 2, 3, 4] Oh well ...