Metasyntactic variable

From Wikipedia, the free encyclopedia
Jump to: navigation, search
This article is about metasyntactic variables in computer science and hacker culture. For metasyntactic variables as used in formal logic, see Metavariable (logic). For general usage, see placeholder name.

A metasyntactic variable is a placeholder name used in computer science, a word without meaning intended to be substituted by some objects pertaining to the context where it is used. The word foo as used in IETF Requests for Comments is a good example.[1]

By mathematical analogy, a metasyntactic variable is a word that is a variable for other words, just as in algebra letters are used as variables for numbers.[1]

A standard convention is that any file with 'foo' in its name is temporary and can be deleted on sight."[2] The names of these consecrated "metasyntactic variables" are also commonly used as actual identifiers (for variables, functions, etc.) in tutorial programming examples when their purpose is to emphasize syntax; in this usage, "metasyntactic variable" is synonymous with "meaningless word".[3]


RFC 772 (cited in RFC 3092) contains for instance:

 All is well; now the recipients can be specified.

     S: MRCP TO:<Foo@Y> <CRLF>
     R: 200 OK

     S: MRCP TO:<Raboof@Y> <CRLF>
     R: 553  No such user here

     S: MRCP TO:<bar@Y> <CRLF>
     R: 200 OK

     S: MRCP TO:<@Y,@X,fubar@Z> <CRLF>
     R: 200 OK

  Note that the failure of "Raboof" has no effect on the storage of
  mail for "Foo", "bar" or the mail to be forwarded to "fubar@Z"
  through host "X".

Both the IETF RFCs and computer programming languages are rendered in plain text, making it necessary to distinguish metasyntactic variables by a naming convention, more or less obvious from context. If rich text formatting is available, e.g. as in the HTML produced from texinfo sources, then a typographical convention may be used, as done for the example in the GNU Fortran manual:[4]

The above example uses italics to denote metavariables (borrowing from the common convention to use italics for variables in mathematics), although italics are also used in the same text for emphasizing other words. (The documentation for texinfo emphasizes the distinction between metavariables and mere variables used in a programming language being documented in some texinfo file as: "Use the @var command to indicate metasyntactic variables. A metasyntactic variable is something that stands for another piece of text. For example, you should use a metasyntactic variable in the documentation of a function to describe the arguments that are passed to that function. Do not use @var for the names of particular variables in programming languages. These are specific names from a program, so @code is correct for them."[5]) Another point reflected in the above example is the convention that a metavariable is to be uniformly substituted with the same instance in all its appearances in a given schema. This is in contrast with nonterminal symbols in formal grammars where the nonterminals on the right of a production can be substituted by different instances.[6]

A third example of the use of the "metasyntactic variables" foo and bar, this time as actual identifiers in a programming (interview) example is contrasting the following C++ function prototypes for their different argument passing mechanisms:[7]

void foo(Fruit bar);
void foo(Fruit* bar);
void foo(Fruit& bar);

Words commonly used as metasyntactic variables[edit]


Metasyntactic variables used in the United States include foobar, foo, bar, baz, qux, quux, quuz, corge, grault, garply, waldo, fred, plugh, xyzzy, and thud.[1][8] Wibble, wobble, wubble, and flob are used in the UK.[9] And there are a reported blep, blah, and boop from Australia.[10][11]

Due to English being the foundation-language, or lingua franca, of most computer programming languages these variables are also commonly seen even in programs and examples of programs written for other spoken-language audiences.

The typical names may depend however on the subculture that has developed around a given programming language. For example, spam, ham, and eggs are the principal metasyntactic variables used in the Python programming language.[12] This is a reference to the comedy sketch Spam by Monty Python, the eponym of the language.[13]

The R programming language often adds norf to the list.[14]


In Japanese, the words hoge and piyo are commonly used, with other common words and variants being fuga, hogera, and hogehoge.[15] Note that -ra is a pluralizing ending in Japanese, and reduplication is also used for pluralizing. The origin of hoge as a metasyntactic variable is not known, but it is believed to date to the early 1980s.[15]


In Portuguese, the words fulano, sicrano and beltrano are commonly used to refer to people.[16]


In Spanish, the words fulano,[17] mengano[18] perengano,[19] and zutano[20] are commonly used, often followed by de tal ("of such"), mocking a lastname in Spanish form (e.g. Fulano de Tal).

See also[edit]


  1. ^ a b c RFC 3092 (rfc3092) - Etymology of "Foo"
  2. ^ As reproduced in Hank Bromley; Richard Lamson (1987). Lisp lore: a guide to programming the Lisp machine. Kluwer Academic. p. 291. 
  3. ^ Mark Slagell (2002). Sams Teach Yourself Ruby in 21 Days. Sams Publishing. p. 108. ISBN 978-0-672-32252-5. 
  4. ^
  5. ^
  6. ^ R. D. Tennent (2002). Specifying Software: A Hands-On Introduction. Cambridge University Press. pp. 36–37 and 210. ISBN 978-0-521-00401-5. 
  7. ^ John Mongan; Noah Kindler; Eric Giguere (2012). Programming Interviews Exposed: Secrets to Landing Your Next Job. John Wiley & Sons. p. 242. ISBN 978-1-118-28720-0. 
  8. ^ quuz. Retrieved November 18, 2016, from programming@ProgClub
  9. ^ wibble. (n.d.). Jargon File 4.4.7. Retrieved February 23, 2010, from [1]
  10. ^ blep. Retrieved November 18, 2016, from programming@ProgClub
  11. ^ blah, boop. Retrieved November 19, 2016, from programming@ProgClub
  12. ^ Python Tutorial
  13. ^ General Python FAQ
  14. ^
  15. ^ a b メタ構文変数 (Japanese)
  16. ^
  17. ^
  18. ^
  19. ^
  20. ^

External links[edit]