Misplaced Pages

Metasyntactic variable: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Browse history interactively← Previous editNext edit →Content deleted Content addedVisualWikitext
Revision as of 19:25, 29 January 2008 editFox (talk | contribs)Administrators33,217 edits Fixing links to disambiguation pages using AWB← Previous edit Revision as of 14:54, 3 February 2008 edit undoDumZiBoT (talk | contribs)212,289 editsm Bot: Converting bare referencesNext edit →
Line 19: Line 19:
A "standard list of metasyntactic variables used in syntax examples" is: foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud.<ref name="RFC3092">http://www.faqs.org/rfcs/rfc3092.html</ref> The word ''foo'' occurs in over 330 ]s 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.<ref name="RFC3092">http://www.faqs.org/rfcs/rfc3092.html</ref> The word ''foo'' occurs in over 330 ]s and ''bar'' occurs in over 290.{{Fact|date=January 2008}}<!-- <ref>http://www.rfc-editor.org/download.html</ref> -->


'']'' is used in one section of a tutorial on the ] by ]. Here, he illustrates the use of the ''extern'' ]:<ref>http://www.lysator.liu.se/c/bwk-tutor.html</ref> '']'' is used in one section of a tutorial on the ] by ]. Here, he illustrates the use of the ''extern'' ]:<ref></ref>
<pre> <pre>
Second, at the beginning of any file Second, at the beginning of any file
Line 31: Line 31:
</pre> </pre>


], ], and ] are the canonical metasyntactic variables used in the ].<ref>http://docs.python.org/tut/</ref> This is a reference to the famous comedy sketch, '']'', by ], the namesake of the language.<ref>http://www.python.org/doc/faq/general/#why-is-it-called-python</ref> ], ], and ] are the canonical metasyntactic variables used in the ].<ref></ref> This is a reference to the famous comedy sketch, '']'', by ], the namesake of the language.<ref></ref>
In this extract from the Python tutorial showing the use of ]s,<ref>http://docs.python.org/tut/node5.html</ref> ''STRING'' is a metasyntactic variable. In this extract from the Python tutorial showing the use of ]s,<ref></ref> ''STRING'' is a metasyntactic variable.
<pre> <pre>
Some examples: Some examples:
Line 42: Line 42:
</pre> </pre>


''Arfle'', ''barfle'', and ''gloop'', which are commonly used by those with a ] or ] background, originated as the response of the parser of a ] BBC Micro ] to input it didn't understand.<ref>http://www.everything2.com/index.pl?node_id=550120</ref> An example of these can be seen in this ] bug report, along with other interesting metasyntactic variables.<ref>http://gcc.gnu.org/ml/gcc-bugs/2000-02/msg00244.html</ref> ''Arfle'', ''barfle'', and ''gloop'', which are commonly used by those with a ] or ] background, originated as the response of the parser of a ] BBC Micro ] to input it didn't understand.<ref></ref> An example of these can be seen in this ] bug report, along with other interesting metasyntactic variables.<ref></ref>
The author of this ] has written an example program for the sole purpose of demonstrating the ]. He provides "a ] which lays out some ]s" using names that are arbitrary, but ] required: The author of this ] has written an example program for the sole purpose of demonstrating the ]. He provides "a ] which lays out some ]s" using names that are arbitrary, but ] required:
<pre> <pre>

Revision as of 14:54, 3 February 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.

Any word can be used as a metasyntactic variable however "nonsense words" are commonly used to denote that they are being used as such. 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

By dissection the word

  • 'Meta' means information about, more comprehensive, 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.

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

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. The word foo occurs in over 330 RFCs and bar occurs in over 290.

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:

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. This is a reference to the famous comedy sketch, Spam, by Monty Python, the namesake of the language. In this extract from the Python tutorial showing the use of comments, 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."

Arfle, barfle, and gloop, which are commonly used by those with a BBC Micro or ZX Spectrum background, originated as the response of the parser of a Level 9 BBC Micro adventure game to input it didn't understand. An example of these can be seen in this GCC bug report, along with other interesting metasyntactic variables. The author of this bug report has written an example program for the sole purpose of demonstrating the bug. He provides "a source file which lays out some vtables" using names that are arbitrary, but syntactically required:

...
struct Side
{
  virtual ~Side ();
  virtual void Arfle ();
  virtual void Barfle ();
  virtual void Gloop ();
  virtual void Glorp ();
  virtual void Glump ();
  virtual void Bogus  ();  
};
...

See also

References

  1. ^ http://www.faqs.org/rfcs/rfc3092.html
  2. Brian W. Kernighan: Programming in C: A Tutorial
  3. Python Tutorial
  4. General Python FAQ
  5. 3. An Informal Introduction to Python
  6. arfle barfle gloop?@Everything2.com
  7. [C++ bug] Recent vtable regression

External links

Category: