Jump to content

Metasyntactic variable

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 69.47.185.144 (talk) at 02:37, 5 September 2004. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computer programming, a metasyntactic variable is a kind of alias, a name commonly 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. The use of metasyntactic variables is also helpful in that they free the programmer from having to think up a logically named variable for the topic under discussion.

The phenomenon is similar to the use in algebra of x, y and z for unknown variables, and a, b and c for unknown constants.

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.

Examples

Nonsense words

Foo, Bar and Baz

Foo is the first metasyntactic variable, commonly used to represent an as-yet-unspecified term, value, process, function, destination or event but seldom a person (see Ned Baker, below). 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 f***ed/fouled up beyond all recognition, although the Jargon File makes a reasonably good case that foo predates fubar. Foo was also used as a nonsense word in the surrealistic comic strip Smokey Stover that was popular in the 1940s and 1950s. It appears to be unrelated to Kung fu. See also Foo fighter for more foo etymology, as well as RFC 3092.

Bar, the canonical second metasyntactic variable. Typically follows foo.

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

Quux

Quux is the canonical fourth metasyntactic 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.

Bat

Bat is used by some programmers as an alternative to quux.

Xyzzy

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

English words

Spam and Eggs

Spam and eggs are the canonical metasyntactic variables used in the Python programming language. This is a reference to a famous comedy sketch by Monty Python, after whom the language is named.

Other examples

Other words used as metasyntactic variables include: test, mum, thud, beekeeper, hoge, corge, grault, garply, waldo, plugh, kalaa, puppu, dothestuff, temp, var, sub.

Numbers

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, where Deep Thought concluded that it was 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.

4711

4711 is most commonly used in German computer speak as a random member of a set. It is a brand of Eau de Cologne, originally named after the number of the manufacturer's house in Cologne.

Names of people

J. Random and Ned Baker

J. Random and Ned Baker are the names of archetypical users; compare to "The Joneses". J. Random Hacker and J. Random User are also common.

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)
  • Charlie - a challenger or opponent

Bob, Alice and Carol may have come from the 1969 movie Bob & Carol & Ted & Alice, or from the fact that they are common English names starting with A, B and C, the first letters of the alphabet.

Fred and Barney

After the characters in the cartoon series The Flintstones.

Other names

Sometimes placeholders from other contexts will be used: John Doe, Jane Roe, Richard Roe, A N Other, John Q. Public.

Other languages

Other languages sometimes have their own metasyntactic variables. For example:

  • Aap, Noot, Mies - from Dutch
  • pippo, pluto, paperino - from Italian
  • toto, tata, titi - from French
  • hoge, hogehoge, moge - from Japanese
  • peh, meh, shmeh - from Yiddish
  • teleledningsanka (phone cable duck) - from Swedish
  • bla, la - from Portuguese
  • huu, haa - from Finnish
  • kalatehas (fish factory) - from Estonian
  • schlurps, schnurz, Lieschen Mueller - from German