Metasyntactic variable

Metasyntactic variable

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.[1]

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 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.[1]

Contents

Construction

  • meta- means providing information about, or transcending,
  • syntax denotes the grammatical arrangement of words or the grammatical rules of a programming language, and
  • a variable 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, xyzzy, thud.[1] The word foo occurs in over 330 RFCs and bar occurs in over 290.[2] Wibble, wobble, wubble, Fred and flob are often used in the UK.[3]

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.[4] 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.[4]

Israeli Hebrew

In Hebrew, the words chupchick and stam are commonly used.

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 Goofy, but it is probably used just because of its sound which is quite strange.

Portuguese

In Portuguese, the words fulano, ciclano and beltrano are commonly used. These words have the constraint that they can only be used to refer to people.

Programming language examples

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.

// The function named foo
int foo(void)
{
   // Declare the variable bar and set the value to 1
   int bar = 1;
 
   return bar;
}

Python

Spam, ham, and eggs are the principal metasyntactic variables used in the Python programming language.[5] This is a reference to the famous comedy sketch, Spam, by Monty Python, the eponym of the language.[6] In the following example spam, ham, and eggs are metasyntactic variables and lines beginning with # are comments.

# Define a function named spam
def spam():
 
    # define the variable ham
    ham = "Hello World!"
 
    #define the variable eggs
    eggs = 1
 
    return


Ruby

In the following example the baz, foo, and bar are metasyntactic variables and lines beginning with # are comments.

# Declare the variable foo and set equal to 1
foo = 1
 
# Declare the variable bar and set equal to 2
bar = 2
 
# Declare the method (function) named baz, which prints the text 'Hello world'
def baz
   puts 'Hello world'
end

See also

References

  1. ^ a b c RFC 3092 (rfc3092) - Etymology of "Foo"
  2. ^ RFC-Editor.org
  3. ^ wibble. (n.d.). Jargon File 4.4.7. Retrieved February 23, 2010, from [1]
  4. ^ a b メタ構文変数 (Japanese)
  5. ^ Python Tutorial
  6. ^ General Python FAQ

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • metasyntactic variable — noun A conventional variable name used for an unspecified entity whose exact nature depends on context. Use metasyntactic variables like foo and bar when you need a name but the particular name doesnt matter …   Wiktionary

  • metasyntactic — adjective Used in describing syntax See Also: metasyntactic variable …   Wiktionary

  • Temporary variable — In computer programming, a temporary variable is a variable whose purpose is short lived, usually to hold temporarily data that will soon be discarded, or before it can be placed at a more permanent memory location. Because it is short lived, it… …   Wikipedia

  • Metasyntaktische Variable — Eine metasyntaktische Variable ist eine Variable in Computer Programmcode, die ausschließlich zur Benennung von beliebigen Entitäten in Beispielen dient. Eine metasyntaktische Variable hat ansonsten keine Bedeutung. Der Begriff stammt aus der… …   Deutsch Wikipedia

  • Foo — is a metasyntactic variable used heavily in computer science to represent concepts abstractly and can be used to represent any part of a complicated system or idea including the data, variables, functions, and commands. Foo is commonly used with… …   Wikipedia

  • Metavariable — Eine metasyntaktische Variable ist eine Variable in Computer Programm Code, die ausschließlich zur Benennung von beliebigen Entitäten in Beispielen dient. Eine metasyntaktische Variable hat ansonsten keine Bedeutung. Der Begriff stammt aus der… …   Deutsch Wikipedia

  • TypeParameter — In computer programming languages, TypeParameter is a frequently used generic label used in templates to reference an unknown data type, data structure, or class. Templates are most frequently used in Java and C++. TypeParameter is similar to a… …   Wikipedia

  • Outline of logic — The following outline is provided as an overview of and topical guide to logic: Logic – formal science of using reason, considered a branch of both philosophy and mathematics. Logic investigates and classifies the structure of statements and… …   Wikipedia

  • Python (programming language) — infobox programming language name = Python paradigm = multi paradigm: object oriented, imperative, functional year = 1991 designer = Guido van Rossum developer = Python Software Foundation latest release version = 2.6 latest release date =… …   Wikipedia

  • Alice and Bob — The 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… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”