M4_(language) M4_(language)

M4 (language) - Definition and Overview

Related Words: Afghan, Afghani, Afrikaans, Ainu, Akan, Akkadian, Albanian, Aleut, Algonquian, Algonquin, Amharic, Anatolian, Andaman, Apache, Arabic, Aramaic, Araucanian, Arawak, Arawakan, Armenian, Aryan, Assamese
The title given to this article is incorrect due to technical limitations. The correct title is "m4 macro language".

m4 is a macro processing language.

A macro processor is a text-replacement tool. Its chief use is to re-use text templates, typically in programming applications, but also in text editing, text processing applications. One of the most widespread uses is as part of the GNU autoconf.

Macro processors were prevalent when assembly language programming was the common tool of programmers. In these early days of programming, the programmers noted that much of their program was repeated text. Simple means to re-use this text were invented. Programmers soon discovered it easy to not only reuse entire blocks of text, but, on occasion, substitute different values for similar parameters. This defined the usage range of macro processors.

m4 offers these facilities:

  • text replacement
  • parameter substitution
  • file inclusion
  • string manipulation
  • conditional evaluation
  • arithmetic expressions
  • system interface
  • programmer diagnostics

Unlike most earlier macro processors, it is not targeted at any particular computer or human language; historically, however, it was developed for supporting the ratfor dialect of Fortran. Unlike some other macro processors, m4 is Turing-complete as well as a practical programming language.

A simple example (using the GNU extension patsubst to construct the definition of bye from that of hi):

define(`hi', `Hello, $1')
define(`bye', patsubst(patsubst(defn(`hi'), 
                       `,', ````,' ' ' '), 
               Hello, Good-``by'e')`, have a good time')
hi(Tom)!
bye(Tom)!

After being processed with m4:

m4 inputfile >outputfile

the outputfile will contain some blank lines followed by

Hello, Tom!
Good-bye, Tom, have a good time!

There is a GNU version of m4.

External links


Example Usage of (language)

LunchBagArt: Sorry: Mickey Roarke Raps. Warning: language. http://www.youtube.com/watch?v=NsusJVaAWf8&feature=related
saraduhh: #MM Body Language - T-Pain Feat. Jesse McCartney
PaulaVaccaro: RT @Cathyroxx: Omg I can't believe I follow people who I don't even know what language they're talking LOL
Copyright 2009 WordIQ.com - Privacy Policy  :: Terms of Use  :: Contact Us  :: About Us
This article is licensed under the GNU Free Documentation License. It uses material from the this Wikipedia article.