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. 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.
Metasyntactic variables are so called because:
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.
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/fouled up beyond all recognition, although the Jargon File makes a pretty 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, is a kind of alias, commonly used to represent an as-yet-unspecified term, value, process, function, destination or event, but seldom a person (see Ned Baker, below). Typically follows foo.
baz, the canonical third metasyntactic variable, is commonly used after foo and bar.
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 is used by some programmers as an alternative to quux.
Other words used as metasyntactic variables include: test, mum, thud, beekeeper, hoge, corge, grault, garply, waldo, plugh, kalaa, puppu, dothestuff, temp, var, sub.
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.
After the characters in the cartoon series The Flintstones.
Other languages sometimes have their own metasyntactic variables. For example: