PLDB
Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

M4

M4

M4 is a pl created in 1977 by Brian Kernighan and Dennis Ritchie.

#322on PLDB 45Years Old 715Users
2Books 0Papers 2kRepos

Try now: Riju · TIO

m4 is a general-purpose macro processor included in all UNIX-like operating systems, and is a component of the POSIX standard. The language was designed by Brian Kernighan and Dennis Ritchie for the original versions of UNIX. It is an extension of an earlier macro processor m3, written by Ritchie for the AP-3 minicomputer. Read more on Wikipedia...


Example from Riju:
errprint(`Hello, world!')
Example from hello-world:
Hello
Example from the Hello World Collection:
# Hello World for the m4 macro processor Hello
Example from Linguist:
dnl Took from https://en.wikipedia.org/wiki/M4_(computer_language) divert(-1) M4 has multiple output queues that can be manipulated with the `divert' macro. Valid queues range from 0 to 10, inclusive, with the default queue being 0. Calling the `divert' macro with an invalid queue causes text to be discarded until another call. Note that even while output is being discarded, quotes around `divert' and other macros are needed to prevent expansion. # Macros aren't expanded within comments, meaning that keywords such # as divert and other built-ins may be used without consequence. # HTML utility macro: define(`H2_COUNT', 0) # The H2_COUNT macro is redefined every time the H2 macro is used: define(`H2', `define(`H2_COUNT', incr(H2_COUNT))<h2>H2_COUNT. $1</h2>') divert(1)dnl dnl dnl The dnl macro causes m4 to discard the rest of the line, thus dnl preventing unwanted blank lines from appearing in the output. dnl H2(First Section) H2(Second Section) H2(Conclusion) dnl divert(0)dnl dnl <HTML> undivert(1)dnl One of the queues is being pushed to output. </HTML>
Example from Wikipedia:
<HTML> <h2>1. First Section</h2> <h2>2. Second Section</h2> <h2>3. Conclusion</h2> </HTML>

Language features

Feature Supported Example Token
Line Comments
# A comment
#
Comments
Semantic Indentation ϴ

Books about M4 from ISBNdb

title authors year publisher
ARM® Cortex® M4 Cookbook Dr. Mark Fisher 16-03-2016 Packt Publishing
Getting Started with Tiva ARM Cortex M4 Microcontrollers Dhananjay V. Gadre; Sarthak Gupta 20171016 Springer Nature
objective-j.html · m4.html · mmx.html

View source

PLDB - Build the next great programming language · v2022 · Day 32 · Docs · Build · Acknowledgements · Traffic Today · Traffic Trends · Mirrors · GitHub · feedback@pldb.com