Difference between revisions of "Macro"
From Computer History Wiki
(A start...) |
(Not just languages) |
||
Line 1: | Line 1: | ||
− | '''Macros''' are text substitions provided in [[programming language]] [[source code|sources]] | + | '''Macros''' are text substitions provided in [[programming language]] [[source code|sources]], and also in some [[application]]s. First seen in [[assembly language|assembler]]s, they later appeared in higher-level languages such as [[C (language)|C]]. |
Modern highly optimizing compilers (which are prepared to do inline expansion of calls to small subroutines) have made them obsolescent now. | Modern highly optimizing compilers (which are prepared to do inline expansion of calls to small subroutines) have made them obsolescent now. | ||
− | The operation is fairly straight-forward: if macro 'foo' is defined to produce 'barzap', then when the string 'foo' is seen in the source, it is replaced with 'barzap'. | + | The operation is fairly straight-forward: if macro 'foo' is defined to produce 'barzap', then when the string 'foo' is seen in the source (or input, in an application), it is replaced with 'barzap'. |
More complex macros can take arguments, and the replacement string includes special syntax to show where to substitute argument strings. | More complex macros can take arguments, and the replacement string includes special syntax to show where to substitute argument strings. |
Revision as of 00:56, 15 December 2017
Macros are text substitions provided in programming language sources, and also in some applications. First seen in assemblers, they later appeared in higher-level languages such as C.
Modern highly optimizing compilers (which are prepared to do inline expansion of calls to small subroutines) have made them obsolescent now.
The operation is fairly straight-forward: if macro 'foo' is defined to produce 'barzap', then when the string 'foo' is seen in the source (or input, in an application), it is replaced with 'barzap'.
More complex macros can take arguments, and the replacement string includes special syntax to show where to substitute argument strings.