3 ms·
Interesting. Isn't that a good fit for macros though? Particularly for the future maintainers sake. With macros, future maintainers will only need to tweak macr
by kangalioo 5y ago
Interesting. Isn't that a good fit for macros though? Particularly for the future maintainers sake. With macros, future maintainers will only need to tweak macro invocations or macro bodies, instead of having to do a huge copy paste job all over again
- gmadsen 5y agopossibly, I know in some industries you can't use macros due to security audits
- asutekku 5y agoAnd then you have to waste couple of hours to do the macro which might or might not be used in the future.
- wizzwizz4 5y agoEven when I have to look up all the weird syntax for a macro_rules! macro, they take like 10 minutes, tops. If you're taking much longer than that, you're probably trying something too ambitious: it should either be proper code generation (in Rust, a build script or proc macro) or a const fn, or a trait and proper generics. C's even easier; you just write the C code with parens around everything, then run it through cpp, then correct any divergences from the expected code. (It does take a bit longer, though, because the compiler waits until the last minute to shout at you if you make a syntax error.) I can see complicated C++ templates taking hours, but they're not really macros. (They're probably the correct tool for this, though.)