4 ms·
A macro is a bit like a template in web programming. You define a structure and some variables that will be filled in. The difference to a template is, a templa
by thibran 5y ago
A macro is a bit like a template in web programming. You define a structure and some variables that will be filled in. The difference to a template is, a template does not respect context, a macro does.
For example, let's say your language had 'if' but not 'case', then it would be possible to write a case macro that in the end transforms at compile time into a bunch of ifs. Macros allows you to create new language syntax and express your intent more clearly.