User:Kf4yfd/msv

Source: Wikipedia, the free encyclopedia.

In

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

foo is the principal example.[1]

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

variable for other words, just as in algebra letters are used as variables for numbers.[1]

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,

plugh, xyzzy, thud.[1] The word foo occurs in over 330 RFCs and bar occurs in over 290.[2] Wibble, wobble, wubble and flob are often used in the UK.[3]

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 function named foo
int foo(void)
{
   // Declare the variable bar and set the value to 1
   int bar = 1;

   return bar;
}


The

Python programming language
:
Spam, by Monty Python, the eponym of the language.[5]
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


The

Ruby programming language
: 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. ^ Python Tutorial
  5. ^ General Python FAQ

External links