Main Page | See live article | Alphabetical index

Metasyntactic variable

In computer programming, a metasyntactic variable is a name used in examples and understood by hackers and programmers to stand for whatever thing is under discussion, or any random member of a class of things under discussion. The word foo is the canonical example.

Metasyntactic variables are so called because:

  1. they are variables in the metalanguage used to talk about programs etc (see also pseudocode);
  2. they are variables whose values are often variables (as in usages like "the value of f( foo, bar ) is the sum of foo and bar").
However, it has been plausibly suggested that the real reason for the term metasyntactic variable is that it sounds good: the term is a piece of computer jargon.

Table of contents
1 Examples

Examples

Foo and Bar

Foo is the first metasyntactic variable commonly used. It is sometimes combined with bar to make foobar. This suggests that foo may have originated with the World War II slang term fubar, as an acronym for fucked up beyond all recognition. Foo was also used as a nonsense word in the surrealistic comic strip Smokey Stover that was popular in the 1940s and 1950s. See also Foo Fighters for more foo etymology.

Foo is a kind of alias, commonly used to represent an as-yet-unspecified term, value, process, function, destination or event, but seldom a person.

The jargon file has an extensive etymology of the word foo at [1]. The IETF also published a memo on the subject: see RFC 3092.

Baz

baz is the canonical third metasyntactic variable, commonly used after foo and bar.

Quux

Quux is the canonical fourth metasyntic variable, commonly used after baz. However more recently Qux has become more common as the fourth variable, displacing Quux as the fifth. A probable reason for this is that Quux is often followed by the series Quuux, Quuuux, Quuuuux etc. and Qux fits this pattern perfectly.

xyzzy

xyzzy is the 'magic word' from the Colossal Cave Adventure, and as such is often used as a metasyntic variable, especially by old-school hackers.

42

The number 42 is often a common initializer for integer variables, and acts as in the same vein as a "metasyntactic value". It is taken from Douglas Adams The Hitchhiker's Guide to the Galaxy. It is The Answer to Life, the Universe, and Everything.

47

The number 47 is sometimes used instead of 42 above, and is used mainly by members of the 47 society, or New Trek fans.

J. Random

J. Random is the name of an archetypical user, compare to "The Jones'".

Alice and Bob

Alice and Bob are names of the archetypal individuals used as examples in discussions of cryptographic protocols. Others include Carol (a participant in three- and four-party protocols), Dave (a participant in four-party protocols), Eve (an eavesdropper), Mallory (a malicious active attacker), Trent (a trusted arbitrator), Walter (a warden), Peggy (a prover), Victor (a verifier), Sam (a trusted server - Uncle Sam) and Charlie (a challenger/opponent).

Fred & Barney

After the characters in the cartoon series The Flintstones.

Other examples

mum, thud, beekeeper, hoge, corge, grault, garply, waldo, plugh, kalaa, puppu, dothestuff.

Sometimes placeholders from other contexts will be used, typically John Doe, Richard Roe, A N Other.

Algebra

This is similar to algebraic variables which are usually x, y, and z for unknown variables and a, b, and c for constants.

Other languages sometimes have their own metasyntic variables, for example Aap, Noot, Mies from Dutch, pippo, pluto, paperino from Italian etc..