Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Metaprogramming
(section)
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!
== Uses in programming languages == === Macro systems === {{main|Macro (computer science)}} * [[Lisp (programming language)|Lisp]], most dialects ** [[Clojure (programming language)|Clojure]] ** [[Common Lisp]] ** [[Racket (programming language)|Racket]] ** [[Scheme (programming language)|Scheme]] [[hygienic macro]]s * [[MacroML]] * [[Template Haskell]] * [[Scala (programming language)|Scala]] * [[Nim (programming language)|Nim]] * [[Rust (programming language)|Rust]] * [[Haxe]] * [[Julia (programming language)|Julia]] * [[Elixir (programming language)|Elixir]] === Macro assemblers === {{main|Macro assembler}} The [[IBM/360]] and derivatives had powerful [[macro assembler]] facilities that were often used to generate complete [[assembly language]] programs {{Citation needed|date=August 2011}} or sections of programs (for different operating systems for instance). Macros provided with [[CICS]] [[transaction processing]] system had assembler macros that generated [[COBOL]] statements as a pre-processing step. Other assemblers, such as [[MASM]], also support macros. === Metaclasses === {{main|Metaclass}} [[Metaclass]]es are provided by the following programming languages: * [[Common Lisp]]<ref>Through [[Common Lisp Object System]]'s "Meta Object Protocol"</ref> * [[Python (programming language)|Python]] * [[NIL (programming language)|NIL]] * [[Groovy (programming language)|Groovy]] * [[Ruby (programming language)|Ruby]] * [[Smalltalk]] * [[Lua (programming language)|Lua]] === Template metaprogramming === {{main|Template metaprogramming}} * [[X Macro|C "X Macros"]] * [[C++ Templates]]<ref>{{Cite web |title=C++ Template Metaprogramming |url=http://aszt.inf.elte.hu/~gsd/halado_cpp/ch06s04.html |access-date=2022-07-23 |website=aszt.inf.elte.hu}}</ref> * [[D (programming language)|D]] * [[Common Lisp]], [[Scheme (programming language)|Scheme]] and most Lisp dialects by using the quasiquote ("backquote") operator.<ref>[[Lisp (programming language)]] "Self-evaluating forms and quoting", quasi-quote operator.</ref> * [[Nim (programming language)|Nim]] === Staged metaprogramming === {{main|Multi-stage programming}} * MetaML * [[OCaml#MetaOCaml|MetaOCaml]] * [[Scala (programming language)|Scala]] [https://docs.scala-lang.org/scala3/reference/metaprogramming.html natively] or using the Lightweight Modular Staging Framework<ref>{{Cite web|url=https://scala-lms.github.io/|title=LMS: Program Generation and Embedded Compilers in Scala|website=scala-lms.github.io|language=en|access-date=2017-12-06}}</ref><ref>{{Cite journal|last1=Rompf|first1=Tiark|last2=Odersky|first2=Martin|date=June 2012|title=Lightweight Modular Staging: A Pragmatic Approach to Runtime Code Generation and Compiled DSLs|journal=Communications of the ACM|volume=55|issue=6|pages=121β130|doi=10.1145/2184319.2184345|s2cid=52898203|issn=0001-0782|url=http://infoscience.epfl.ch/record/178274}}</ref> * [http://terralang.org Terra] === Dependent types === {{main|Dependent type}} Use of [[dependent type]]s allows proving that generated code is never invalid.<ref>{{cite journal|last=Chlipala|first=Adam|title=Ur: statically-typed metaprogramming with type-level record computation|journal=ACM SIGPLAN Notices|date=June 2010|volume=45|series=PLDI '10|issue=6|pages=122β133|doi=10.1145/1809028.1806612|url=http://adam.chlipala.net/papers/UrPLDI10/UrPLDI10.pdf|access-date=29 August 2012}}</ref> However, this approach is leading-edge and rarely found outside of research programming languages.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)