Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Macro (computer science)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Applications === ; Evaluation order :Macro systems have a range of uses. Being able to choose the order of evaluation (see [[lazy evaluation]] and [[Strict function|non-strict functions]]) enables the creation of new syntactic constructs (e.g. [[control structures]]) indistinguishable from those built into the language. For instance, in a Lisp dialect that has <CODE>cond</CODE> but lacks <CODE>if</CODE>, it is possible to define the latter in terms of the former using macros. For example, Scheme has both [[continuation]]s and hygienic macros, which enables a programmer to design their own control abstractions, such as looping and early exit constructs, without the need to build them into the language. ; Data sub-languages and domain-specific languages : Next, macros make it possible to define data languages that are immediately compiled into code, which means that constructs such as [[state machine]]s can be implemented in a way that is both natural and efficient.<ref>{{cite web|url=http://cs.brown.edu/~sk/Publications/Papers/Published/sk-automata-macros/|title=Automata via Macros|website=cs.brown.edu}}</ref> ; Binding constructs :Macros can also be used to introduce new binding constructs. The most well-known example is the transformation of <CODE>let</CODE> into the application of a function to a set of arguments. [[Matthias Felleisen|Felleisen]] conjectures<ref name="three-uses">[http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg01539.html], Matthias Felleisen, LL1 mailing list posting</ref> that these three categories make up the primary legitimate uses of macros in such a system. Others have proposed alternative uses of macros, such as [[anaphoric macro]]s in macro systems that are unhygienic or allow selective unhygienic transformation. The interaction of macros and other language features has been a productive area of research. For example, [[Software component|component]]s and [[Modular programming|module]]s are useful for large-scale programming, but the interaction of macros and these other constructs must be defined for their use together. Module and component-systems that can interact with macros have been proposed for Scheme and other languages with macros. For example, the [[Racket (programming language)|Racket]] language extends the notion of a macro system to a syntactic tower, where macros can be written in languages including macros, using hygiene to ensure that syntactic layers are distinct and allowing modules to export macros to other modules.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Macro (computer science)
(section)
Add topic