PLDB
Languages Features Calendar About Lists Add Language
GitHub icon

Macros

Macros

Macros are a language feature.

A macro (short for "macroinstruction", from Greek μακρός 'long') in computer science is a rule or pattern that specifies how a certain input sequence (often a sequence of characters) should be mapped to a replacement output sequence (also often a sequence of characters) according to a defined procedure.

Languages without Macros include Java, JavaScript, Kotlin

Languages with Macros include C, C++, Rust, Scheme, Clojure, Erlang, Racket, Nim, Factor, honu

Example from C:

https://gcc.gnu.org/onlinedocs/cpp/Macro-Arguments.html

Example from C++:

https://msdn.microsoft.com/en-us/library/503x3e3s.aspx

Example from Rust:

https://doc.rust-lang.org/book/ch19-06-macros.html

Example from Scheme:

https://en.wikibooks.org/wiki/Scheme_Programming/Macros

Example from Clojure:

https://clojure.org/reference/macros

Example from Erlang:

-define(Const, Replacement). -define(Func(Var1,...,VarN), Replacement).

Example from Racket:

https://docs.racket-lang.org/guide/macros.html

Example from Nim:

https://hookrace.net/blog/introduction-to-metaprogramming-in-nim/#macros

Article source

PLDB - Build the next great programming language. v5.0.0 - Acknowledgements · Email · GitHub