|
|
|
|
Hello, I am Jeff, How Are you? I can see you! Hope you have fun at lunch! See you soon. chicken |
|
{{about|metasyntactic variables in computer science and programming|metasyntactic variables as used in formal logic|Metavariable (logic)|usage in spoken languages|placeholder name}} |
|
|
|
Minecraft is crap, kys |
|
A '''metasyntactic variable''' is a specific word or set of words identified as a [[placeholder name|placeholder]] in [[computer science]] and specifically [[computer programming]]. These words are commonly found in [[source code]] and are intended to be modified or substituted to be applicable to the specific usage before [[Compiler|compilation]] (translation to an [[executable]]). The words '''foo''' and '''bar''' are good examples as they are used in over 330 [[Internet Engineering Task Force]] [[Request for Comments|Requests for Comments]], which are documents explaining foundational internet technologies like [[HTTP]](websites), [[TCP/IP]], and [[email]] [[Communications protocol|protocol]]s.<ref name="RFC3092">[https://www.ietf.org/rfc/rfc3092.txt RFC 3092 (rfc3092) - Etymology of "Foo"]</ref><ref>[http://www.rfc-editor.org/download.html RFC-Editor.org]</ref> |
|
|
|
|
|
By mathematical [[analogy]], a metasyntactic variable is a word that is a [[Variable (mathematics)|variable]] for other words, just as in [[algebra]] letters are used as variables for numbers.<ref name="RFC3092"/> |
|
|
|
|
|
Metasyntactic variables are used to name entities such as variables, functions, and commands whose exact identity is unimportant and serve only to demonstrate a concept, which is useful for teaching programming. |
|
|
|
|
|
|
|
|
==Common Metasyntactic Variables== |
|
|
Due to English being the foundation-language, or [[lingua franca]], of most computer programming languages these variables are commonly seen even in programs and examples of programs written for other spoken-language audiences. |
|
|
|
|
|
The typical names may depend however on the subculture that has developed around a given [[programming language]]. |
|
|
|
|
|
===General Usage=== |
|
|
Metasyntactic variables used commonly across all programming languages: [[foobar]], foo, bar, baz, qux, quux, quuz, corge, grault, garply, waldo, fred, [[plugh]], [[xyzzy (computing)|xyzzy]], and thud.<ref name="RFC3092"/><ref>''quuz''. Retrieved November 18, 2016, from [https://www.progclub.org/pipermail/programming/2016-November/002305.html programming@ProgClub]</ref> ''Wibble'', ''wobble'', ''wubble'', and ''flob'' are used in the UK.<ref>''wibble''. (n.d.). Jargon File 4.4.7. Retrieved February 23, 2010, from [http://catb.org/jargon/html/enwiki/w/wibble.html]</ref> And there are a reported ''blep'', ''blah'', and ''boop'' from Australia.<ref>''blep''. Retrieved November 18, 2016, from [https://www.progclub.org/pipermail/programming/2016-November/002301.html programming@ProgClub]</ref><ref>''blah'', ''boop''. Retrieved November 19, 2016, from [https://www.progclub.org/pipermail/programming/2016-November/002309.html programming@ProgClub]</ref> |
|
|
|
|
|
A complete reference can be found in a [[MIT Press]] book titled: [[The Hacker's Dictionary]]. |
|
|
|
|
|
===Python=== |
|
|
[[Spam (food)|spam]], ham, and eggs are the principal metasyntactic variables used in the [[Python programming language]].<ref>[https://docs.python.org/tut/ Python Tutorial]</ref> This is a reference to the comedy sketch ''[[Spam (Monty Python)|Spam]]'' by [[Monty Python]], the eponym of the language.<ref>[https://www.python.org/doc/faq/general/#why-is-it-called-python General Python FAQ]</ref> |
|
|
|
|
|
===R=== |
|
|
The [[R programming language]] often adds ''norf'' to the list.<ref>http://use-r.com/coursera-r-programming-week-2/</ref> |
|
|
|
|
|
===French=== |
|
|
In French, the words are ''toto'' and its derivatives, replacing ''o'' by other vowels: ''tata'', ''titi'', ''tutu''... It may come from ''Toto'' who is the main character in many French jokes.<ref>[[:fr:Variable métasyntaxique#Toto]]</ref>{{Better source|reason=per WP:CIRCULAR|date=February 2017}} |
|
|
|
|
|
===Japanese=== |
|
|
In Japanese, the words ''hoge'' (ほげ)<ref>http://ejje.weblio.jp/content/hoge</ref> and ''piyo'' (ぴよ) are commonly used, with other common words and variants being ''fuga" (ふが), "hogera'' (ほげら), and ''hogehoge'' (ほげほげ).<ref name="ja">[[:ja:メタ構文変数|メタ構文変数]] {{ja-icon}}</ref>{{Better source|reason=per WP:CIRCULAR|date=September 2017}} 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.<ref name="ja" /> |
|
|
|
|
|
== Usage Examples == |
|
|
|
|
|
===[[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. |
|
|
<source lang="cpp"> |
|
|
|
|
|
// The function named foo |
|
|
int foo(void) |
|
|
{ |
|
|
// Declare the variable bar and set the value to 1 |
|
|
int bar = 1; |
|
|
|
|
|
return bar; |
|
|
} |
|
|
</source> |
|
|
|
|
|
|
|
|
===[[Python programming language]]=== |
|
|
[[Spam (food)|Spam]], [[ham]], and [[Egg (food)|eggs]] are the principal metasyntactic variables used in the [[Python programming language]].<ref>[http://docs.python.org/tut/ Python Tutorial]</ref> This is a reference to the famous comedy sketch, ''[[Spam (Monty Python)|Spam]]'', by [[Monty Python]], the eponym of the language.<ref>[http://www.python.org/doc/faq/general/#why-is-it-called-python General Python FAQ]</ref> |
|
|
In the following example '''spam''', '''ham''', and '''eggs''' are metasyntactic variables and lines beginning with '''#''' are comments. |
|
|
<source lang="python"> |
|
|
# Define a function named spam |
|
|
def spam(): |
|
|
|
|
|
# define the variable ham |
|
|
ham = "Hello World!" |
|
|
|
|
|
#define the variable eggs |
|
|
eggs = 1 |
|
|
|
|
|
return |
|
|
</source> |
|
|
|
|
|
|
|
|
===[[Ruby programming language]]=== |
|
|
In the following example the '''baz''', '''foo''', and '''bar''' are metasyntactic variables and lines beginning with '''#''' are comments. |
|
|
<source lang="ruby"> |
|
|
# 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 |
|
|
</source> |
|
|
|
|
|
===[[IETF]] [[Request for Comments]]=== |
|
|
Both the [[IETF]] [[Request for Comments|RFC]]s and [[computer programming language]]s are rendered in [[plain text]], making it necessary to distinguish metasyntactic variables by a naming convention, since it would not be obvious from context. |
|
|
|
|
|
Plain text example: |
|
|
|
|
|
RFC 772 (cited in RFC 3092) contains for instance: |
|
|
All is well; now the recipients can be specified. |
|
|
|
|
|
S: MRCP TO:<Foo@Y> <CRLF> |
|
|
R: 200 OK |
|
|
|
|
|
S: MRCP TO:<Raboof@Y> <CRLF> |
|
|
R: 553 No such user here |
|
|
|
|
|
S: MRCP TO:<bar@Y> <CRLF> |
|
|
R: 200 OK |
|
|
|
|
|
S: MRCP TO:<@Y,@X,fubar@Z> <CRLF> |
|
|
R: 200 OK |
|
|
|
|
|
Note that the failure of "Raboof" has no effect on the storage of |
|
|
mail for "Foo", "bar" or the mail to be forwarded to "fubar@Z" |
|
|
through host "X". |
|
|
|
|
|
(The documentation for texinfo emphasizes the distinction between metavariables and mere variables used in a programming language being documented in some texinfo file as: "Use the @var command to indicate metasyntactic variables. A metasyntactic variable is something that stands for another piece of text. For example, you should use a metasyntactic variable in the documentation of a function to describe the arguments that are passed to that function. Do not use @var for the names of particular [[Variable (programming)|variables]] in programming languages. These are specific names from a program, so @code is correct for them."<ref>http://sunsite.ualberta.ca/Documentation/Gnu/texinfo-4.0/html_chapter/texinfo_10.html</ref>) |
|
|
|
|
|
Another point reflected in the above example is the convention that a metavariable is to be uniformly substituted with the same instance in all its appearances in a given schema. This is in contrast with [[nonterminal]] symbols in [[formal grammars]] where the nonterminals on the right of a production can be substituted by different instances.<ref name="Tennent2002">{{cite book|author=R. D. Tennent|title=Specifying Software: A Hands-On Introduction|year=2002|publisher=Cambridge University Press|isbn=978-0-521-00401-5|pages=36–37 and 210}}</ref> |
|
|
|
|
|
==Teaching Concepts== |
|
|
This section includes bits of code which show how metasyntactic variables are used in teaching computer programming concepts. |
|
|
|
|
|
===[[C++]]=== |
|
|
Function prototypes with different [[Parameter (computer programming)#Argument passing|argument passing]] mechanisms:<ref name="MonganKindler2012">{{cite book|author1=John Mongan|author2=Noah Kindler|author3=Eric Giguere|title=Programming Interviews Exposed: Secrets to Landing Your Next Job|url=https://books.google.com/books?id=GQE4r2e5fAsC&pg=PA242|year=2012|publisher=John Wiley & Sons|isbn=978-1-118-28720-0|page=242}}</ref> |
|
|
<source lang="cpp"> |
|
|
void foo(Fruit bar); |
|
|
void foo(Fruit* bar); |
|
|
void foo(Fruit& bar); |
|
|
</source> |
|
|
|
|
|
Example showing the [[function overloading]] capabilities of the C++ language |
|
|
<source lang="cpp"> |
|
|
void foo(int bar); |
|
|
void foo(int bar, int baz); |
|
|
void foo(int bar, int baz, int qux); |
|
|
</source> |
|
|
|
|
|
|
|
|
==See also== |
|
|
*[[Metavariable (logic)]] |
|
|
*[[Xyzzy_(computing)|xyzzy]] |
|
|
*[[Alice and Bob]] |
|
|
*[[John Doe]] |
|
|
*[[Fnord]] |
|
|
*[[Free variables and bound variables]] |
|
|
*[[Gadget]] |
|
|
*[[Lorem ipsum]] |
|
|
*[[Nonce word]] |
|
|
*[[Placeholder name]] |
|
|
*[[Widget (economics)|Widget]] |
|
|
*[[The Smurfs#Language|Smurf]] |
|
|
|
|
|
==References== |
|
|
{{Reflist}} |
|
|
|
|
|
==External links== |
|
|
*[http://www.catb.org/jargon/html/M/metasyntactic-variable.html Definition of ''metasyntactic variable'', with examples.] |
|
|
*[http://www.catb.org/jargon/html/C/Commonwealth-Hackish.html Examples of metasyntactic variables] used in ''[[Commonwealth of Nations|Commonwealth]] Hackish'', such as ''wombat''. |
|
|
*[http://blog.codinghorror.com/variable-foo-and-other-programming-oddities/ Variable "foo" and Other Programming Oddities] |
|
|
|
|
|
{{DEFAULTSORT:Metasyntactic Variable}} |
|
|
[[Category:Placeholder names]] |
|
|
[[Category:Metalogic]] |
|
|
[[Category:Variable (computer science)]] |
|
|
[[Category:Syntax (logic)]] |
|