4 ms·
Lisp macros can take arbitrary parameters and are written in lisp. C++ macros can only take types and numbers (until variadic), and writing any code to operate
by liontwist 2y ago
Lisp macros can take arbitrary parameters and are written in lisp.
C++ macros can only take types and numbers (until variadic), and writing any code to operate on those inputs is challenging.
- dataangel 2y agoC++ templates can also take other C++ templates (the template itself, not just an instantiation), enum values and I think in C++23 maybe even structs but I need to check
- jandrewrogers 2y agoC++20 added the ability to take class instances as non-type parameters but the rules around the types of classes that can be used in this way are pretty restrictive (for good reason).
- spacechild1 2y agoThe post is actually about template metaprogramming. 'template macroprogramming' isn't really a thing.
- knome 2y agohttps://github.com/knome/metabrainfuck/blob/master/bf.cpp https://github.com/knome/metabrainfuck/blob/master/bf.cpp It's not too bad :)
- binary132 2y agoYes, the purpose of C++ templates (not macros, macros are C preprocessor) is to implement generic classes and functions, not to implement arbitrary computation, and (iirc) it was only discovered after their publication that they are in fact Turing-complete.