User:Kf4yfd/msv

In computer programming, a metasyntactic variable is a variable whose name is arbitrary and subject to change at the discretion of the programmer. This is in contrast to a metavariable, whose name is unchangable within the given programming language.

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.

Any symbol or word which does not violate the rules of the language can be used as a metasyntactic variable, but nonsense words 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.

Etymology

 * 'Meta' means providing information about, or transcending.
 * 'Syntax' means the grammatical arrangement of words or the grammatical rules of a programming language.
 * 'Variable' means something that can assume a value, or something likely to vary.

So we have a word that


 * transcends grammar and can assume a value

or one that


 * is more comprehensive than 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, xyzzy, thud. The word foo occurs in over 330 RFCs and bar occurs in over 290. Wibble, wobble, wubble and flob are often used in the UK.

Programming language examples
The C programming language: In the following example the function name foo and the variable name bar are both metasyntactic variables. Lines beginning with // are comments.

The Python programming language: Spam, 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.

The Ruby programming language: In the following example the baz, foo, and bar are  metasyntactic variables and lines beginning with # are comments.