Metasyntactic variable
Encyclopedia
In computer science
, programmers use metasyntactic variables to describe a placeholder name
or an alias
term commonly used to denote the subject matter under discussion or an arbitrary member of a class of things under discussion. The use of a metasyntactic variable is helpful in freeing a programmer from creating a logically named variable, which is often useful when creating or teaching examples of an algorithm
. The word foo is the principal example.
The term "metasyntactic variable" is primarily found in informal literature. It is sometimes also used as a synonym for metavariable
.
Any symbol or word which does not violate the rules of the language can be used as a metasyntactic variable, but nonsense word
s are commonly used. The same concept is employed in other fields where it is expressed by terms such as schematic variable (see logical form
).
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.
So metasyntactic variable denotes a word that "transcends grammar and can assume a value" or one that is "more comprehensive than suggested by its grammatical arrangement and is likely to vary".
, thud. The word foo occurs in over 330 RFCs
and bar occurs in over 290. Wibble, wobble, wubble, Fred and flob are often used in the UK.
In standard, non-computerese English, the usual metasyntactic variables are: whatever, whoever, whenever, et cetera.
, but it is probably used just because of its sound which is quite strange.
, ham
, and eggs
are the principal metasyntactic variables used in the Python programming language. This is a reference to the famous comedy sketch, Spam
, by Monty Python
, the eponym of the language.
In the following example spam, ham, and eggs are metasyntactic variables and lines beginning with # are comments.
Computer science
Computer science or computing science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems...
, programmers use metasyntactic variables to describe a placeholder name
Placeholder name
Placeholder names are words that can refer to objects or people whose names are either temporarily forgotten, irrelevant, or unknown in the context in which they are being discussed...
or an alias
Aliasing (computing)
In computing, aliasing describes a situation in which a data location in memory can be accessed through different symbolic names in the program. Thus, modifying the data through one name implicitly modifies the values associated to all aliased names, which may not be expected by the programmer...
term commonly used to denote the subject matter under discussion or an arbitrary member of a class of things under discussion. The use of a metasyntactic variable is helpful in freeing a programmer from creating a logically named variable, which is often useful when creating or teaching examples of an algorithm
Algorithm
In mathematics and computer science, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. Algorithms are used for calculation, data processing, and automated reasoning...
. The word foo is the principal example.
The term "metasyntactic variable" is primarily found in informal literature. It is sometimes also used as a synonym for metavariable
Metavariable
In logic, a metavariable is a symbol or symbol string which belongs to a metalanguage and stands for elements of some object language. For instance, in the sentence...
.
Any symbol or word which does not violate the rules of the language can be used as a metasyntactic variable, but nonsense word
Nonsense word
A nonsense word, unlike a sememe, may have no definition. If it can be pronounced according to a language's phonotactics, it is a logatome. Nonsense words are used in literature for poetic or humorous effect. Proper names of real or fictional entities are sometimes nonsense words.-See...
s are commonly used. The same concept is employed in other fields where it is expressed by terms such as schematic variable (see logical form
Logical form
In logic, the logical form of a sentence or set of sentences is the form obtained by abstracting from the subject matter of its content terms or by regarding the content terms as mere placeholders or blanks on a form...
).
By mathematical analogy
Analogy
Analogy is a cognitive process of transferring information or meaning from a particular subject to another particular subject , and a linguistic expression corresponding to such a process...
: A metasyntactic variable is a word
Word
In language, a word is the smallest free form that may be uttered in isolation with semantic or pragmatic content . This contrasts with a morpheme, which is the smallest unit of meaning but will not necessarily stand on its own...
that is a variable
Variable (programming)
In computer programming, a variable is a symbolic name given to some known or unknown quantity or information, for the purpose of allowing the name to be used independently of the information it represents...
for other words, just as in algebra
Algebra
Algebra is the branch of mathematics concerning the study of the rules of operations and relations, and the constructions and concepts arising from them, including terms, polynomials, equations and algebraic structures...
letters are used as variables for numbers.
Construction
- metaMetaMeta- , is a prefix used in English to indicate a concept which is an abstraction from another concept, used to complete or add to the latter....
- means providing information about, or transcending, - syntaxSyntaxIn linguistics, syntax is the study of the principles and rules for constructing phrases and sentences in natural languages....
denotes the grammatical arrangement of words or the grammatical rules of a programming language, and - a variableVariable (programming)In computer programming, a variable is a symbolic name given to some known or unknown quantity or information, for the purpose of allowing the name to be used independently of the information it represents...
is something that can assume a value, or something likely to vary.
So metasyntactic variable denotes a word that "transcends grammar and can assume a value" or one that is "more comprehensive than suggested by its grammatical arrangement and is likely to vary".
Words commonly used as metasyntactic variables
A "standard list of metasyntactic variables used in syntax examples" often used in the United States is: foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzyXyzzy
Xyzzy is a magic word from the Colossal Cave Adventure computer game.In computing, the word is sometimes used as a metasyntactic variable or as a video game cheat code, the canonical "magic word"...
, thud. The word foo occurs in over 330 RFCs
Request for Comments
In computer network engineering, a Request for Comments is a memorandum published by the Internet Engineering Task Force describing methods, behaviors, research, or innovations applicable to the working of the Internet and Internet-connected systems.Through the Internet Society, engineers and...
and bar occurs in over 290. Wibble, wobble, wubble, Fred and flob are often used in the UK.
In standard, non-computerese English, the usual metasyntactic variables are: whatever, whoever, whenever, et cetera.
Japanese
In Japanese, the words hoge and pakeratta are commonly used, with other common words and variants being piyo, fuga, hogera, and hogehoge. 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.Italian
In Italian, the word pippo is commonly used. Strangely enough, besides being an abbreviation of the first name Filippo (Philip), pippo is the Italian name of the Disney character GoofyGoofy
Goofy is a cartoon character created in 1932 at Walt Disney Productions. Goofy is a tall, anthropomorphic dog, and typically wears a turtle neck and vest, with pants, shoes, white gloves, and a tall hat originally designed as a rumpled fedora. Goofy is a close friend of Mickey Mouse and Donald Duck...
, but it is probably used just because of its sound which is quite strange.
Portuguese
In Portuguese, the words fulano, cicrano and beltrano are commonly used. These words have the constraint that they can only be used to refer to people.C
In the following example of the C programming language the function name foo and the variable name bar are both metasyntactic variables. Lines beginning with // are comments.Python
SpamSpam (food)
Spam is a canned precooked meat product made by the Hormel Foods Corporation, first introduced in 1937. The labeled ingredients in the classic variety of Spam are chopped pork shoulder meat, with ham meat added, salt, water, modified potato starch as a binder, and sodium nitrite as a preservative...
, ham
Ham
Ham is a cut of meat from the thigh of the hind leg of certain animals, especiallypigs. Nearly all hams sold today are fully cooked or cured.-Etymology:...
, and eggs
Egg (food)
Eggs are laid by females of many different species, including birds, reptiles, amphibians, and fish, and have probably been eaten by mankind for millennia. Bird and reptile eggs consist of a protective eggshell, albumen , and vitellus , contained within various thin membranes...
are the principal metasyntactic variables used in the Python programming language. This is a reference to the famous comedy sketch, Spam
Spam (Monty Python)
"Spam" is a popular Monty Python sketch, first televised in 1970. In the sketch, two customers are in a greasy spoon café trying to order a breakfast from a menu that includes the processed meat product in almost every dish. The term spam is derived from this sketch...
, by Monty Python
Monty Python
Monty Python was a British surreal comedy group who created their influential Monty Python's Flying Circus, a British television comedy sketch show that first aired on the BBC on 5 October 1969. Forty-five episodes were made over four series...
, the eponym of the language.
In the following example spam, ham, and eggs are metasyntactic variables and lines beginning with # are comments.
Ruby
In the following example the baz, foo, and bar are metasyntactic variables and lines beginning with # are comments.See also
- Metavariable (logic)
- Alice and BobAlice and BobThe names Alice and Bob are commonly used placeholder names for archetypal characters in fields such as cryptography and physics. The names are used for convenience; for example, "Alice sends a message to Bob encrypted with his public key" is easier to follow than "Party A sends a message to Party...
- John DoeJohn DoeThe name "John Doe" is used as a placeholder name in a legal action, case or discussion for a male party, whose true identity is unknown or must be withheld for legal reasons. The name is also used to refer to a male corpse or hospital patient whose identity is unknown...
- FnordFnordFnord is the typographic representation of disinformation or irrelevant information intending to misdirect, with the implication of a worldwide conspiracy....
- Free variables and bound variablesFree variables and bound variablesIn mathematics, and in other disciplines involving formal languages, including mathematical logic and computer science, a free variable is a notation that specifies places in an expression where substitution may take place...
- GadgetGadgetA gadget is a small technological object that has a particular function, but is often thought of as a novelty. Gadgets are invariably considered to be more unusually or cleverly designed than normal technological objects at the time of their invention...
- Hello World
- Lorem IpsumLorem ipsumIn publishing and graphic design, lorem ipsum[p] is placeholder text commonly used to demonstrate the graphics elements of a document or visual presentation, such as font, typography, and layout...
- Nonce wordNonce wordA nonce word is a word used only "for the nonce"—to meet a need that is not expected to recur. Quark, for example, was formerly a nonce word in English, appearing only in James Joyce's Finnegans Wake. Murray Gell-Mann then adopted it to name a new class of subatomic particle...
- Placeholder namePlaceholder namePlaceholder names are words that can refer to objects or people whose names are either temporarily forgotten, irrelevant, or unknown in the context in which they are being discussed...
- WidgetWidget (economics)The word widget is a placeholder name for an object or, more specifically, a mechanical or other manufactured device. It is an abstract unit of production. The Oxford English Dictionary defines it as "An indefinite name for a gadget or mechanical contrivance, esp. a small manufactured item" and...
External links
- Definition of metasyntactic variable, with examples.
- Examples of metasyntactic variables used in CommonwealthCommonwealth of NationsThe Commonwealth of Nations, normally referred to as the Commonwealth and formerly known as the British Commonwealth, is an intergovernmental organisation of fifty-four independent member states...
Hackish, such as wombat. - Variable "foo" and Other Programming Oddities