Jump to content

Metasyntactic variable: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
→‎Words commonly used as metasyntactic variables: The cited source may not contain the numbers directly, but they are readily derived from the information therein
Line 22: Line 22:


==Words commonly used as metasyntactic variables==
==Words commonly used as metasyntactic variables==
A "standard list of metasyntactic variables used in syntax examples" is: foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud, mos, henk, def.<ref name="RFC3092"/> The word ''foo'' occurs in over 330 [[Request for Comments|RFCs]] and ''bar'' occurs in over 290.{{Fact|date=January 2008}}<!-- <ref>http://www.rfc-editor.org/download.html</ref> -->
A "standard list of metasyntactic variables used in syntax examples" is: foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud, mos, henk, def.<ref name="RFC3092"/> The word ''foo'' occurs in over 330 [[Request for Comments|RFCs]] and ''bar'' occurs in over 290.<ref>http://www.rfc-editor.org/download.html</ref>


''[[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 (computer science)|declaration]]:<ref>[http://www.lysator.liu.se/c/bwk-tutor.html Brian W. Kernighan: Programming in C: A Tutorial]</ref>
''[[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 (computer science)|declaration]]:<ref>[http://www.lysator.liu.se/c/bwk-tutor.html Brian W. Kernighan: Programming in C: A Tutorial]</ref>

Revision as of 19:44, 9 September 2008

A metasyntactic variable (Template:PronEng) is 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 term originates from computer programming and other technical contexts, and is commonly used in examples by hackers and programmers. The use of a metasyntactic variable is helpful in freeing a programmer from creating a logically named variable, although the invented term may also become sufficiently popular and enter the language as a neologism. The word foo is the canonical example.[1]

Any 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).

Explanation of the concept

Dissecting the word

  • '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.

Mathematical analogy

A metasyntactic variable is as a word that is a variable for other words, just as in algebra letters are used as variables for numbers.[1]

Words commonly used as metasyntactic variables

A "standard list of metasyntactic variables used in syntax examples" is: foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud, mos, henk, def.[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 canonical 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] STRING is a metasyntactic variable.

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."

See also

References