Metasyntactic Variable

A word, used in conversation or text that is meant as a variable. There is a fairly standard set in the ComputerScience culture. People tend to create their own if they are not exposed to others, which can be confusing. Of course, if you haven't seen them before they can be quite confusing. They are, however, useful enough that this is not enough reason to give them up.

Standard set: foo, bar, baz, foobar/quux, quuux, quuuux, ....

example: "Suppose I have a list, foo, with a node, bar, ..."

Surely these should be called MetaSyntacticWossnames.
Many ProgrammingLanguages have MetasyntacticVariables built into the language itself, such as the common counted loop indices I and J.

No, this is exactly what metasyntactic variables are *not*. "i" and "j" in this context are known to be integer (and may be more constrained by particular languages)

And "i" as well as "j" in such cases are ordinary (object language) variables, not metasyntactic variables.

Hence God is real. Unless declared integer


In Italian there is a trend towards Disney character names, typically Pippo (Goofy), Pluto, Paperino (Donald Duck) in this order. Sometimes also as identifiers in actual code. --LorenzoGatti


Personal favorites: bullwinkle, rocky, fee, fie, fo, fum. --DavidBrantley

For the sake of being different, perhaps, I use: foo,bar,baz,quux,spam,ni,ecky,ptong. Even my worst TemporaryHack hasn't yet needed more than eight MetasyntacticVariables... yet I say... -- KarlKnechtel

--Have you tried "Frozz" and "Bozz"? I learned them from the book that taught me Python.

Never use metasyntactic variables as real variables! That obscures their meaning.


I recently read that the approved MetasyntacticVariable for an URL is http://example.com/ . It's not supposed to work, but has since May 2002, thanks to bad interpretation of an RFC.

This is the text found on example.com as of July 2005: ''You have reached this web page by typing "example.com", "example.net", or "example.org" into your web browser.

These domain names are reserved for use in documentation and are not available for registration. See RFC 2606, Section 3.''

The TopLevelDomain .invalid is now defined for much the same use.

I like http://www.yes.no/ .

Actually, RFC 2606 does state that
 3. Reserved Example Second Level Domain Names

The Internet Assigned Numbers Authority (IANA) also currently has the following second level domain names reserved which can be used as examples. example.com example.net example.org

-- DorKleiman


MetasyntacticVariables oppose SelfDocumentingCode.

Not really. Because MetasyntacticVariables are never (properly) used in actual code; they are useful at a higher level of abstraction.
AliceAndBob (cryptography). Also Eve represents the one trying to decypher your encrypted data (I think from eavesdropper).

Also, "Trudy," for intruder. ''I thought "Trent" was used for TrustedThirdParty?. Duplicate "T"s ? I've come across an intruder named "Inigo". The firewall was referred to as "Fezzik". I remember that protocol design well...

Use MetasyntacticVariables for teaching only, not for production code. A teacher would use a list, foo, with a node, bar, to indicate that lists and nodes can appear in any domain. The lack of specificity here is an asset. On the other hand, never name an instance variable of a working class foo.

The upshot is that the teacher doesn't have to waste brain cycles coming up with more meaningful names. (How many times can you populate a list with "Bugs", "Wile E.", "Daffy", and "Yosemite Sam") On the other hand, I find my students seem to understand my examples better when I don't foo-bar-baz them. It seems that Yet Another Level of Abstraction is just too much to take.
I never liked foo and bar, and I never use them. It's better to use terms that have some meaning, and let your audience extrapolate from a single meaningful data point.

Well, you may not like them, but a huge number of people find them useful. They are abused sometimes, but in other cases are a far better rhetorical device. Often your 'meaningful data point' will either be a worthless cooked example, or a real example that introduces pointless and distracting detail. Where what you need is an arbitrary example, foo fits the bill. Sure, but x and y sound more natural for that purpose. Maybe that's because I studied math and physics before I entered the software industry.

x and y are not association-free; they are conventionally used to represent the ordinate and the abscissa.
Occasionally a similar concept pops up in normal human language (see BloodyOath).
Note also the use of 42 (FortyTwo) as a MetasyntacticNumber. 23 (TheIlluminati Number) is also a good MetasyntacticNumber.
The practice of metasyntactic variables predates computing, as in "Tom, Dick or Harry" or in Spanish, "Fulano, Zutano, and Meningo." For some reason, there always seem to be three of them.

Good things come in threes: Larry, Curly and Moe; Manny, Moe and Jack; Winken, Blinken and Nod; Meshach, Shedrach and Abednego. Gesundheit!

(See RuleOfThree)

In one company I kept coming across really bad code in a production system - invariably signed 'BAZ'. This, I guessed, was a convention programmers at that company used for their 'quick fix hacks', a bit like adding a comment 'KLUDGE' or 'TO_DO'. No one wanted to put their real initials to the change log for such hacks.

I discovered my mistake when Baz dropped in to the company to visit his former colleagues.


My favorite metasyntactic variables come from Mad Magazine:

axolotl, borscht, frammistan, farshimmelt, furshlugginer, ganef, halavah, moxie, poiuyt, potrzebie, veeblefetzer

DonaldKnuth published a system of weights and measures using them in 1957 in MadMagazine?.

Get out! I don't suppose you could include a scan of the page in MadMagazine? with his DonaldKnuth's name on it? That would be priceless!

[Hate to be a "me too" guy, but if more requests make it more worth it, please scan it!]

It's copyrighted material, so I won't post it to the internet. Mad has released their back issues on CD-ROM, though, so you can buy it. It was in issue #33.

I found it online here: (uhh, how do you link to a gif without inlining it?)


In french, we almost only use toto, titi, tata and tutu in that order.

In cryptography, the metasyntactic characters I met were Alice and Bob (the good guys) and Charlie (the bad one who tries to decypher)...

Eve = an evesdropper. Mallory = an active attacker. See http://www.answers.com/topic/alice-and-bob for a complete list of characters. ;->


And we can't leave without a metasyntactic joke: "A foo walks into a bar..."
See also BadVariableNames

EditText of this page (last edited September 27, 2011) or FindPage with title or text search