Macro (computer science)

jEdit's macro editor

In computer programming, a macro (short for "macro instruction"; from Greek μακρο- 'long, large'[1]) is a rule or pattern that specifies how a certain input should be mapped to a replacement output. Applying a macro to an input is known as macro expansion. The input and output may be a sequence of lexical tokens or characters, or a syntax tree. Character macros are supported in software applications to make it easy to invoke common command sequences. Token and tree macros are supported in some programming languages to enable code reuse or to extend the language, sometimes for domain-specific languages.

Macros are used to make a sequence of computing instructions available to the programmer as a single program statement, making the programming task less tedious and less error-prone.[2][3] Thus, they are called "macros" because a "big" block of code can be expanded from a "small" sequence of characters. Macros often allow positional or keyword parameters that dictate what the conditional assembler program generates and have been used to create entire programs or program suites according to such variables as operating system, platform or other factors. The term derives from "macro instruction", and such expansions were originally used in generating assembly language code.

  1. ^ Oxford English Dictionary, s.v. macro, macro-instruction, and macro-
  2. ^ Greenwald, Irwin D.; Maureen Kane (April 1959). "The Share 709 System: Programming and Modification". Journal of the ACM. 6 (2). New York, NY, USA: ACM: 128–133. doi:10.1145/320964.320967. S2CID 27424222. One of the important uses of programmer macros is to save time and clerical-type errors in writing sequence of instructions which are often repeated in the course of a program.
  3. ^ Strachey, Christopher (October 1965). "A General Purpose Macrogenerator". Computer Journal. 8 (3): 225–241. doi:10.1093/comjnl/8.3.225.

© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search