Teachers Paradise School Supplies Teacher Resources Free Encyclopedia
Teachers Paradise FREE Teaching Resources
Home Arts Crafts Audio Visual Equipment Office Supplies Teacher Resources
Main Page | Edit this page

Macro

A programming language macro is a text abstraction, which defines a name to represent a segment of program text. When a macro is defined, the language system (compiler or interpreter) automatically replaces instances of the macro name with replacement text. The amount of text used in the replacement is typically longer than the amount of text used to represent the name of the macro, and thus the term macro-expansion is used to describe this process.

Languages such as C and assembly language have simple macro systems, implemented as preprocessors to the compiler or assembler. C preprocessor macros work by simple textual search-and-replace. More elaborate macros are available to C programmers by using an additional text-processing language such as M4.

Lisp languages such as Common Lisp and Scheme have more elaborate macro systems: In Lisp, macros behave like functions transforming program text, with the full language available to express such transformations. Lisp macros are used to define new syntactic constructs. Because of this flexibility Lisp has been titled "a programmable programming language".

Keyboard macros

There are also keyboard macros and editor macros, used interactively on a graphical user interface and text editor, respectively. These allow short sequences of keystrokes substitute for long sequences of commands, and can provide a simple form of automation for repetitive tasks.

Macro languages

A macro language is a programming language in which all or most computation is done by expanding macros. Macro languages are not widely used for general-purpose programming, but are common in text processing applications. Examples include M4 (mentioned previously) and TeX.




Pay for Educational Supplies & Teaching Supplies with Visa, Master Card, American Express, Discover or Paypal.
TeachersParadise.com HOME | Safe Shopping Guarantee | Help Desk
All trademarks & brands are the property of their respective owners.
Legal Notice 2000-2007 TeachersParadise.com, Inc. All Rights Reserved