3 ms·
A "macro", in the sense we are using (i.e. not "C preprocessor macro" or "Excel macro"), is basically a function or procedure that "spits out" (returns) source
by flavio81 9y ago
A "macro", in the sense we are using (i.e. not "C preprocessor macro" or "Excel macro"), is basically a function or procedure that "spits out" (returns) source code. It is writen in the programming language you use, and outputs source in the programming language you use.
In other words, a macro is a program that writes programs.
In languages that make heavy use of macros (like Lisp), a macro is compiled almost transparently, so you can use it as if it were a function. It behaves like a function but can do a lot more.
One simple use is to eliminate having to write repetitive or "boilerplate" code, since you can just program a macro to write generate code for you. This generation occurs on the fly and transparently, so the code is more maintainable as well.