Professional Documents
Culture Documents
Macro (Computer Science)
Macro (Computer Science)
Macro (Computer Science)
A macro (short for "macroinstruction", from Greek combining form μακρο- 'long,
large'[1]) in computer science 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
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.
The programmers' text editor, Emacs, (short for "editing macros") follows this
idea to a conclusion. In effect, most of the editor is made of macros. Emacs was
originally devised as a set of macros in the editing language TECO; it was later
ported to dialects of Lisp.
Another programmers' text editor, Vim (a descendant of vi), also has full
implementation of macros. It can record into a register (macro) what a person
types on the keyboard and it can be replayed or edited just like VBA macros for
Microsoft Office. Vim also has a scripting language called Vimscript[5] to create
macros.
Visual Basic for Applications (VBA) is a programming language included in
Microsoft Office from Office 97 through Office 2019 (although it was available in
some components of Office prior to Office 97). However, its function has evolved
from and replaced the macro languages that were originally included in some of
these applications.
Macro virus
Main article: Macro virus (computing)
VBA has access to most Microsoft Windows system calls and executes when
documents are opened. This makes it relatively easy to write computer viruses in
VBA, commonly known as macro viruses. In the mid-to-late 1990s, this became
one of the most common types of computer virus. However, during the late 1990s
and to date, Microsoft has been patching and updating their programs. In
addition, current anti-virus programs immediately counteract such attacks.