In logic, mathematics and computer science, a metasyntactic variable (pronounced /ˌmɛtəsɪnˈtæktɪk ˈvɛəriəbl/) (also metalinguistic variable) is a symbol or set of symbols in a metalanguage which stands for a symbol or set of symbols in some object language. For instance, in the sentence:
The symbols A and B are not symbols of the object language ℒ, they are metasyntactic variables in the metalanguage (in this case, English) which is talking about the object 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. The word foo is the principal example.[1]
Any symbol or word 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).
Contents |
So we have a word that
or one that
A metasyntactic variable is a word that is a variable for other words, just as in algebra letters are used as variables for numbers.[1]
A "standard list of metasyntactic variables used in syntax examples" is: foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud.[1] The word foo occurs in over 330 RFCs and bar occurs in over 290.[2]
Foo is used in one section of a tutorial on the C programming language by Brian W. Kernighan. Here, he illustrates the use of the extern declaration:[3]
Second, at the beginning of any file that contains functions needing a variable whose definition is in some other file, put in an extern declaration, outside of any function: extern int foo; f1( ) { ... } etc.
Spam, ham, and eggs are the principal metasyntactic variables used in the Python programming language.[4] This is a reference to the famous comedy sketch, Spam, by Monty Python, the namesake of the language.[5] In this extract from the Python tutorial showing the use of comments,[6] SPAM and STRING are metasyntactic variables.
Some examples: # this is the first comment SPAM = 1 # and this is the second comment # ... and now a third! STRING = "# This is not a comment."
Wibble, wobble, wubble and flob are often used in the UK[7]
|