Metasyntactic variable: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
additional examples
 
Line 1: Line 1:
{{Short description|Placeholder term used in computer science}}
A '''metasyntactic variable''' can either be a [[placeholder name]], a kind of [[alias]] term, commonly used to denote the subject matter under discussion, or a random 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 [[hacker]]s and [[programmer]]s. 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#Computer science|canonical]] example.
{{About|metasyntactic variables in computer science and programming|metasyntactic variables as used in formal logic|Metavariable (logic)|usage in spoken languages|Placeholder name}}
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 before real-world usage. For example, [[Foobar|'''foo''' and '''bar''']] are used in over 330 [[Internet Engineering Task Force]] [[Request for Comments|Requests for Comments]], the documents which define foundational internet technologies like [[HTTP]] (web), [[TCP/IP]], and [[email]] [[Communications protocol|protocol]]s.<ref name="RFC3092">{{cite IETF|rfc=3092|title=Etymology of "Foo"|first1=Donald E.|last1=((Eastlake 3rd))|first2=Carl-Uno|last2=Manros|first3=Eric S.|last3=Raymond}}</ref><ref>{{Cite web|url=https://www.rfc-editor.org/retrieve/|title=Document Retrieval|work=RFC Editor}}</ref>


By mathematical [[analogy]], a [[metasyntax|metasyntactic]] variable is a word that is a [[Variable (mathematics)|variable]] for other words, just as in [[algebra]] letters are used as variables for [[number]]s.<ref name="RFC3092"/>
The [[phenomenon]] is similar to the use in [[algebra]] of ''x'', ''y'' and ''z'' for unknown [[variable]]s, and ''a'', ''b'' and ''c'' for unknown [[constant]]s. "[[Widget]]s" are also used in business to indicate an as-yet-unspecified product and are frequently sold by the [[Acme]] company.


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.
Metasyntactic variables are so called because:
# They are variables in the [[metalanguage]] used to talk about [[computer program|program]]s, etc. (see also [[pseudocode]]);
# They are variables whose values are often variables (as in usages like "the value of ''f''(foo, bar) is the sum of foo and bar").
== Examples ==


==Common metasyntactic variables==
=== Nonsense words ===
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]].
==== Foo, Bar and Baz ====
'''''Foo''''' is the first metasyntactic variable, commonly used to represent an as-yet-unspecified term, value, process, function, destination or event but seldom a person (see ''Ned Baker'', below). It is sometimes combined with ''bar'' to make ''foobar''. This suggests that ''foo'' may have originated with the [[World War II]] [[slang]] term ''[[fubar]]'', as an [[acronym]] for ''fucked/fouled up beyond all recognition/repair'', although the [[Jargon File]] makes a reasonably good case [http://www.catb.org/~esr/jargon/html/F/foo.html] that ''foo'' predates ''fubar''. ''Foo'' was also used as a [[nonsense]] word in the [[surrealism|surrealistic]] [[comic strip]] ''[[Smokey Stover]]'' that was popular in the [[1940s]] and [[1950s]]. See also [[Foo fighter]] for more ''foo'' etymology, as well as RFC 3092. Another usage of foo is as an abreviation of the phrase "forward observation officer" (or observer). Apparently FOOs used to go places well forward of normal troops in battle and leave a stylised chalk graffiti of a person looking over a wall with the words "foo was here".


===General usage===
The term "Kung foo" has come to mean skill in computer programming. This is actually used (though misspelled) in the movie [[The Core]].
Metasyntactic variables used commonly across all programming languages include ''[[foobar]]'', ''foo'', ''bar'', ''baz'', ''{{not a typo|qux}}'', ''{{not a typo|quux}}'', ''{{not a typo|corge}}'', ''{{not a typo|grault}}'', ''{{not a typo|garply}}'', ''{{not a typo|waldo}}'', ''{{not a typo|fred}}'', ''{{not a typo|[[plugh]]}}'', ''[[xyzzy (computing)|{{not a typo|xyzzy}}]]'', and ''thud''.<ref name="RFC3092"/><ref>{{cite mailing list|title=Metasyntactic variable|first=Stuart|last=Laughlin|date=November 18, 2016|access-date=November 18, 2016|url=https://www.progclub.org/pipermail/programming/2016-November/002305.html|mailing-list=programming@ProgClub|url-status=dead|archive-url=https://web.archive.org/web/20221202085628/https://www.progclub.org/pipermail/programming/2016-November/002305.html|archive-date=December 2, 2022}}</ref> Two of these words, ''plugh'' and ''xyzzy'', are taken from the game ''[[Colossal Cave Adventure]]''.<ref>{{cite web |url=https://jerz.setonhill.edu/if/crowther/advdat.77-03-11 |title=advdat.77-03-11 |last=Crowther |first=Will |date=1977-03-11 |website= Colossal Cave Adventure Source Code |publisher=Dennis G. Jerz |access-date=2024-02-28}}</ref>


A complete reference can be found in a [[MIT Press]] book titled ''[[The Hacker's Dictionary]]''.
'''''Bar''''', the canonical second metasyntactic variable, typically follows ''foo''.


===Japanese===
'''''Baz''''', the canonical third metasyntactic variable, is commonly used after ''foo'' and ''bar''.
In Japanese, the words {{transl|ja|hoge}} (ほげ)<ref>{{Cite web|url=https://ejje.weblio.jp/content/hoge|title=hogeの意味・使い方 - 英和辞典 Weblio 辞書|website=ejje.weblio.jp}}</ref> and {{transl|ja|fuga}} (ふが) are commonly used, with other common words and variants being piyo (ぴよ), {{transl|ja|hogera}} (ほげら), and {{transl|ja|hogehoge}} (ほげほげ).<ref name="ja">[[:ja:メタ構文変数|メタ構文変数]] {{in lang|ja}}</ref>{{Circular reference|date=September 2017}} The origin of {{transl|ja|hoge}} as a metasyntactic variable is not known, but it is believed to date to the early 1980s.<ref name="ja" />


===French===
''Foo'', ''bar'', and ''baz'' are often compounded together to make such words as ''foobar'', ''barbaz'', and ''foobaz''.
In France, the word ''toto'' is widely used, with variants ''tata'', ''titi'', ''tutu'' as related placeholders. One commonly-raised source for the use of ''toto'' is a reference to the stock character used to tell jokes with [[Tête à Toto]].{{CN|date=February 2022}}


==== Quux ====
===Turkish===
In Turkey, the words ''hede'' and ''hödö'' (usually spelt ''hodo'' due to [[ASCII]]-only naming constraints of programming languages) are well-known metasyntactic variables stemmed from popular humorous cartoon magazines of the 90's like LeMan. The words do not mean anything, and specifically used in place of things that do not mean anything. The terms have been popularized to the masses by the actor and stand-up comedian [[Cem Yılmaz]] in the late 90's and early 2000's.<ref>{{Cite book |url=https://books.google.com/books?id=dRxdDwAAQBAJ&dq=hede+h%C3%B6d%C3%B6&pg=PA12 |title=LeMan Dergisi 1376. Sayı |publisher=Lm Basin Yayin Ltd.şti. |language=tr}}</ref>
''Quux'', introduced by [[Guy L. Steele, Jr.]], is the canonical fourth metasyntactic variable, commonly used after ''baz''. However, more recently ''Qux'' has become more common as the fourth variable, displacing ''Quux'' as the fifth. A probable reason for this is that ''Quux'' is often followed by the series ''Quuux'', ''Quuuux'', ''Quuuuux'' etc. and ''Qux'' fits this [[pattern]] perfectly.


==== Bat ====
===Italian===
In the Italian software programming culture, it is common to encounter names of Walt Disney characters being used as variables. These names often appear in pseudo-code, are referenced in Software Engineering classes, and are commonly employed when explaining algorithms to colleagues. Among the most frequently used are "pippo" (Goofy), "pluto," and "paperino" (Donald Duck). <ref>{{Cite web|url=http://www.catb.org/jargon/html/M/metasyntactic-variable.html|title=The Jargon File - metasyntactic variable|website=www.catb.org/}}</ref>
'''''Bat''''' is used by some programmers as an alternative to ''quuux''.


==== Xyzzy ====
== Usage examples ==
[[File:Metasyntactic Variable FOO in Shell.png|thumb|A screenshot of a metasyntactic variable FOO assigned and echoed in an interactive shell session.]]
The word ''xyzzy'' is the "[[magic word]]" from the [[Colossal Cave Adventure]], and therefore is often used as a metasyntactic variable, especially by [[old school|old-school]] [[hacker]]s.


==== shme ====
===C===
{{See also|C programming language}}
Infrequently used in various environments such as Berkeley, GeoWorks, Ingres, Quovadx. Pronounced /shmeh/ with a short /e/.
In the following example the function name <code>foo</code> and the variable name <code>bar</code> are both metasyntactic variables. Lines beginning with <code>//</code> are comments.
<syntaxhighlight lang="cpp">
// The function named foo
int foo(void)
{
// Declare the variable bar and set the value to 1
int bar = 1;


return bar;
=== English words ===
}
</syntaxhighlight>


==== Spam and Eggs ====
===C++===
{{See also|C++}}
''Spam'' and ''eggs'' are the canonical metasyntactic variables used in the [[Python programming language]]. This is a reference to a [[Spam (Monty Python)|famous comedy sketch]] by [[Monty Python]], after which the language is named.
Function prototypes with examples of different [[Parameter (computer programming)#Argument passing|argument passing]] mechanisms:<ref name="MonganKindler2012">{{cite book|first1=John|last1=Mongan|first2=Noah|last2=Kindler|first3=Eric|last3=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>
<syntaxhighlight lang="cpp">
void Foo(Fruit bar);
void Foo(Fruit* bar);
void Foo(const Fruit& bar);
</syntaxhighlight>


Example showing the [[function overloading]] capabilities of the C++ language
==== Needle and Haystack ====
<syntaxhighlight lang="cpp">
''Needle'' and ''haystack'' are commonly used in [[computer programming]] to describe the syntax of functions that involve a search parameter and a search target, such as searching a substring within a string; with these two words, derived from the [[idiom]] "to find a needle in a haystack", it is clearer where the substring for which to search goes, and where the string in which to search goes. This can be seen, for instance, in the documentation for some functions in the computer language [[PHP]], see [http://www.php.net/substr-count] for an example.
void Foo(int bar);
void Foo(int bar, int baz);
void Foo(int bar, int baz, int qux);
</syntaxhighlight>


==== Other examples ====
===Python===
[[Spam (food)|Spam]], [[ham]], and [[Egg (food)|eggs]] are the principal metasyntactic variables used in the [[Python programming language]].<ref>{{Cite web|url=https://docs.python.org/3/tutorial/|title=The Python Tutorial — Python 3.8.1 documentation|website=docs.python.org}}</ref> This is a reference to the famous comedy sketch, "[[Spam (Monty Python)|Spam]]", by [[Monty Python]], the eponym of the language.<ref>{{Cite web |date=2021-09-04 |title=General Python FAQ — Python 3.9.7 documentation |url=https://docs.python.org/3/faq/general.html |url-status=live |archive-url=https://web.archive.org/web/20210826153036/https://docs.python.org/3/faq/general.html#why-is-it-called-python |archive-date=2021-08-26 |access-date=2021-09-05 |website=docs.python.org |publisher=Python Software Foundation |at=Why is it called Python?}}</ref>
Other words used as metasyntactic variables include:
In the following example <code>spam</code>, <code>ham</code>, and <code>eggs</code> are metasyntactic variables and lines beginning with <code>#</code> are comments.
''beekeeper'', ''[[blah]]'', ''blarg'', ''bleh'', ''corge'', ''doip'', ''dothestuff'', ''garply'', ''glarb'', ''grault'', ''hoge'', ''kalaa'', ''mum'', ''plugh'', ''puppu'', ''sub'', ''temp'', ''test'', ''thud'', ''var'', ''waldo'', ''momo''.
<syntaxhighlight lang="python">
# Define a function named spam
def spam():


# Define the variable ham
''Plugh'', like ''xyzzy'', is a "[[magic word]]" from the [[Colossal Cave Adventure]].
ham = "Hello World!"


# Define the variable eggs
=== Numbers ===
eggs = 1


return
==== 23 ====
</syntaxhighlight>
The number [[23 (number)|23]] is also commonly used as an integer example&mdash;particularly when the connotations associated with 42 are undesirable.


==== 42 ====
===IETF Requests 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.
The number [[42 (number)|42]] is often a common initializer for integer variables, and acts in the same vein as a "metasyntactic value". It is taken from [[Douglas Adams]]' ''[[The Hitchhiker's Guide to the Galaxy]]'', where [[minor characters from The Hitchhiker's Guide to the Galaxy#Deep Thought|Deep Thought]] concluded that it was [[The Answer to Life, the Universe, and Everything]].


Here is an example from the official [[IETF]] document explaining the [[e-mail]] protocols (from RFC 772 - cited in RFC 3092):
==== 47 ====
All is well; now the recipients can be specified.
The number [[47 (number)|47]] is sometimes used instead of 42 above, and is used mainly by members of the [[47 society]], or [[Star Trek|New Trek]] fans.
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>{{cite web |url=http://sunsite.ualberta.ca/Documentation/Gnu/texinfo-4.0/html_chapter/texinfo_10.html |title=Marking Words and Phrases |work=Texinfo 4.0. The GNU Documentation Format|access-date=2012-11-25 |url-status=dead |archive-url=https://web.archive.org/web/20091106004856/http://sunsite.ualberta.ca/Documentation/Gnu/texinfo-4.0/html_chapter/texinfo_10.html |archive-date=2009-11-06 }}</ref>)
==== 69 ====
[[69 (number)|69]] is often used as an example number. Popular among hackers as an addition to metasyntactic variables (foo69, bar69), also used in all sorts of hacks. 69 is popular because of its reference to a [[69 sex position|sexual position]]. It is also because it is the largest number whose [[factorial]] can be calculated by a pocket calculator limited to standard [[scientific notation]] with a 2 digit exponent.


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>
==== 0815 ====
0815 (named after the repetitive and boring [[MG 08|MG 08/15]]-training) is used in [[Germany|German]] as either a random number or to reflect something ''normal'' or ''boring''.


==== 1337 ====
==Example data==
===SQL===
Stands for ''Leet'', in [[Leetspeak]], being, thus, commonly used.
It is common to use the name [[Acme Corporation|ACME]] in example [[SQL]] [[Database]]s and as placeholder company-name for the purpose of teaching. The term 'ACME Database' is commonly used to mean a training or example-only set of database data used solely for training or testing.

ACME is also commonly used in documentation which shows SQL usage examples, a common practice with in many educational texts as well as technical documentation from companies such as [[Microsoft]] and [[Oracle Corporation|Oracle]].<ref name="Kriegel 2008 p.">{{cite book | last=Kriegel | first=Alex | title=SQL bible | publisher=Wiley | publication-place=Indianapolis, Ind | year=2008 | isbn=978-0-470-22906-4 | oclc=402446308 }}</ref><ref name="Ruel 2014 p.">{{cite book | last=Ruel | first=Chris | title=Oracle 12c for dummies | publisher=John Wiley & Sons | publication-place=Hoboken, NJ | year=2014 | isbn=978-1-118-74531-1 | oclc=870334544 | language=da }}</ref><ref>{{Cite web|url=https://docs.microsoft.com/en-us/dotnet/architecture/modern-web-apps-azure/work-with-data-in-asp-net-core-apps|title=Work with data in ASP.NET Core Apps|website=docs.microsoft.com}}</ref>
==== 4711 ====
[[4711]] is most commonly used in German computer speak as a [[random]] member of a [[set]]. It is a [[brand]] of [[Eau de Cologne]], originally named after the number of the manufacturer's house in [[Cologne]].

=== Names of people ===

==== J. Random and Ned Baker ====
''J. Random'' and ''Ned Baker'' are the names of [[archetype|archetypal]] users; compare to "[[Keeping up with the Joneses|The Joneses]]". ''J. Random Hacker'' and ''J. Random User'' are also common.

==== Alice and Bob ====
[[Alice and Bob|''Alice'' and ''Bob'']] are names of the archetypal [[characters in cryptography|individuals]] used as examples in discussions of [[cryptography|cryptographic]] [[protocol (computing)|protocol]]s. Others include:
* ''Carol'' - a participant in three- and four-party protocols
* ''Dave'' - a participant in four-party protocols
* ''Ellen'' - a participant in five- and six-party protocols
* ''Frank'' - a participant in six-party protocols, and so on
* ''Eve'' or ''Oscar'' - an (evil) [[eavesdrop]]per
* ''Mallory'' or ''Mallet'' - a malicious active attacker
* ''Trent'' - a trusted [[arbitration|arbitrator]]
* ''Walter'' - a warden
* ''Peggy'' - a prover
* ''Victor'' - a verifier
* ''Sam'' - a trusted server ([[Uncle Sam]])
* ''Charlie'' - a challenger or opponent
* ''Trudy'' - an intruder or malicious entity

''Bob'', ''Alice'' and ''Carol'' may have come from the [[1969]] [[film|movie]] ''[[Bob & Carol & Ted & Alice]]'', or from the fact that they are common English names starting with ''A'', ''B'' and ''C'', the first letters of the [[alphabet]]. ''Dave'', ''Ellen'', and ''Frank'' are the next three letters. Some people continue this pattern, using ''Gloria'' or another similar term for the seventh participant, and so on (maintaining the pattern ''female, male, female, male...'').

==== Fred and Barney ====
After the characters in the cartoon series ''[[The Flintstones]]''. The most famous use of these is the example code in ''[[Learning Perl]]''. Fred is also known to have been used simply because the keys are close together on the [[QWERTY]] keyboard.

==== Military names ====
Some names are most commonly used in military context.
*''Private Snuffy''
*''Susie Rottencrotch'' or ''Jane Rottencrotch'' from the movie ''[[Full Metal Jacket]]''
*''GI Joe'' or ''GI Jane''
*''[[Beetle Bailey]]'' from the comic strip of the same name
*''[[Gomer Pyle]]'' or ''Private Pyle'' from the television show of the same name, also popularized by the movie ''Full Metal Jacket''

==== Other names ====
Sometimes placeholders from other contexts will be used: [[John Doe]], [[Jane Roe]], [[Richard Roe]], [[A. N. Other]], [[John Q. Public]], [[Bloggs]] or [[Joe Bloggs]], ''Joe Soap'' and ''Tom, Dick and Harry''. In some [[law school|law schools]], the generic case name ''Push v. Pull'' is used as a variable. Law or Accounting firms are sometimes referred to with names like ''Dewey, Cheatham, and Howe'' (Do we cheat 'em, and how!) Other nonsense names come from swapping initials, e.g. [[Peter Jennings|J. Pennings]].

===Place names===

====Smallville and Metropolis====
[[Smallville]] and [[Metropolis (comics)|Metropolis]] are fictional places from the [[Superman]] series of comic books. These are used to contrast urban and rural characteristics.

====Anywhere, Anytown and Nowhere====
Anywhere, USA or Anytown, USA connotes genericness. Nowhere sometimes suggests that the entry is invalid.

====Middle of Nowhere / In the Sticks / East Buttfuck / East Boofu ====
Unlike Nowhere, these metasyntactic variables indicate extreme remoteness and suggest contempt.

====Podunk University====
This term is sometimes a placeholder for a generic university.

====Y.U. Bum University====
This term is sometimes a placeholder for a less generic university. Pronounced like "Why you bum, you."

=== Images ===
[[Test card]]s have been used as standard images and so has [[Lenna]].
== Other languages ==
Other [[language]]s sometimes have their own metasyntactic variables. For example:
* ''Jia'', ''Yi'', ''Bing'', ''Ding'' - from [[Chinese language|Chinese]]
* ''flaf'', ''giraf'', ''boing'' - from [[Danish language|Danish]]
* ''aap'', ''noot'', ''mies'', ''Piet'', ''Jan'', ''Kees'' - from [[Dutch language|Dutch]]
* ''pippo'', ''pluto'', ''paperino'' (Italian names of the [[The Walt Disney Company|Disney]] characters [[Goofy]], [[Pluto (dog)|Pluto]] and [[Donald Duck]]) - from [[Italian language|Italian]]
* ''Maria Bernasconi'' - from [[Italian language|Italian in Switzerland]]
* ''toto'', ''tata'', ''titi'', ''prout'', ''banane'' - from [[French language|French]]
* ''koko'', ''lala'', ''malakia'' - from [[Greek language|Greek]]
* ''hoge'', ''hogehoge'', ''moge'', ''huga'', ''piyo'' - from [[Japanese language|Japanese]]
* ''peh'', ''meh'', ''shmeh'' - from [[Yiddish language|Yiddish]]
* ''bla'', ''nha'', ''la'', ''patati'', ''patata'', ''Fulano'', ''Sicrano'' and ''Beltrano'' (the last three as placeholders for persons' names) - from [[Portuguese language|Portuguese]]
* ''huu'', ''haa'' - from [[Finnish language|Finnish]]
* ''hahaa'', ''hihii'', ''hohoo'' - also from Finnish
* ''kalatehas'' (fish factory) - from [[Estonian language|Estonian]]
* ''muh'', ''bla'', ''blubb'', ''schlurps'', ''schnurz'', ''Lieschen Mueller'' - from [[German language|German]]
* ''bubu'', ''mumu'', ''zeze'' - from [[Romanian language|Romanian]]
* ''brol'', ''prout'' - from [[French language|French in Belgium]]
* ''filan'', ''hede'', ''hödö'', ''z&#305;v&#305;r'', ''&#305;v&#305;r'', ''bok'', ''püsür'', ''ali'', ''veli'', ''deli'' - from [[Turkish language|Turkish]]
* ''fulano'', ''mengano'', ''zutano'' (the three used to denote a supposed or fictional person), ''sultano'' (variant of the previously mentioned "zutano"), ''pepe'' (Joe), ''pp'' (phonetic equivalent to "pepe"), ''vaina,'' (vulgar) ''cosa'' (in Spanish, "cosa" can be anything, but usually refers to some physical object), ''pirola'' (has no meaning) ''pirolita'' (literally, "small pirola"; has no meaning) - from [[Spanish language|Spanish]]
* ''Ploni'' (&#1508;&#1500;&#1493;&#1504;&#1497;) as a person's name; ''Reuven'' (&#1512;&#1488;&#1493;&#1489;&#1503;) and ''Shim'on'' (&#1513;&#1502;&#1506;&#1493;&#1503;) as two persons (after [[Jacob|Jacob]]'s Sons)- from [[Hebrew language|Hebrew]]
* ''Kuppuswamy'', ''Ramaswamy'' - from [[Tamil language|Tamil]]
* ''Gipsz Jakab''; ''alma'', ''körte'', ''barack'' - from [[Hungarian language|Hungarian]]
* ''Phalaan Phalaan'' - from [[Hindi language|Hindi]]
* ''Vasya Pupkin'', ''Private Pupkin'' (&#1042;&#1072;&#1089;&#1103; &#1055;&#1091;&#1087;&#1082;&#1080;&#1085;, &#1088;&#1103;&#1076;&#1086;&#1074;&#1086;&#1081; &#1055;&#1091;&#1087;&#1082;&#1080;&#1085;), meaning abstract person, but generally a soldier or a programmer - from [[Russian language|Russian]]
* ''bla'', ''blahuj'', ''ugg'', ''ugga'', ''blargh'', ''gunk'', ''tjo'', ''[[bork]]''; ''Kalle'', ''Olle'', ''Pelle'', ''Nisse'' (the diminutives of Karl, Olof, Per and Nils respectively) - [[Swedish language|Swedish]]

It may also be interesting to note that lazy programmers who run out of nonsense words simply append numbers when they need more variables.


==See also==
==See also==
*[[Metavariable (logic)]]
*[[Placeholder name]] (Kadigan)
*[[Xyzzy (computing)|xyzzy]]
*[[Alice and Bob]]
*[[John Doe]]
*[[Fnord]]
*[[Free variables and bound variables]]
*[[Free variables and bound variables]]
*[[gadget]]
*[[Gadget]]
*[[widget]]
*''[[Lorem ipsum]]''
*[[Hello World]]
*[[Nonce word]]
*[[Placeholder name]]
*[[Widget (economics)|Widget]]
*[[The Smurfs#Language|Smurf]]


==References==
== External links ==
{{Reflist}}
* [http://www.catb.org/~esr/jargon/html/F/foo.html The Jargon File entry on Foo], and also the entry on [http://www.catb.org/~esr/jargon/html/C/Commonwealth-Hackish.html Commonwealth Hackish] for non-US English words such as "wombat".
* RFC 3092 - The [[IETF]] memo on Foo (note that this is an [[April 1st RFC|April Fool's Day RFC]] memo)
* [http://search.cpan.org/dist/Acme-MetaSyntactic/ Acme::MetaSyntactic] A Perl module providing metasyntactic variable names. Updated weekly.


==External links==
[[category:Programming]]
*[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]


[[Category:Placeholder names]]
[[de:Metasyntaktische Variable]]
[[Category:Metalogic]]
[[fr:Variable métasyntaxique]]
[[Category:Variable (computer science)]]
[[he:משתנה מטה תחבירי]]
[[Category:Syntax (logic)]]
[[pl:Zmienna metasyntaktyczna]]
[[ru:Метапеременная]]
[[fi:Foo]]
[[sv:Metavariabel]]

Latest revision as of 10:35, 22 April 2024

A metasyntactic variable is a specific word or set of words identified as a placeholder in computer science and specifically computer programming. These words are commonly found in source code and are intended to be modified or substituted before real-world usage. For example, foo and bar are used in over 330 Internet Engineering Task Force Requests for Comments, the documents which define foundational internet technologies like HTTP (web), TCP/IP, and email protocols.[1][2]

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]

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[edit]

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[edit]

Metasyntactic variables used commonly across all programming languages include foobar, foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, and thud.[1][3] Two of these words, plugh and xyzzy, are taken from the game Colossal Cave Adventure.[4]

A complete reference can be found in a MIT Press book titled The Hacker's Dictionary.

Japanese[edit]

In Japanese, the words hoge (ほげ)[5] and fuga (ふが) are commonly used, with other common words and variants being piyo (ぴよ), hogera (ほげら), and hogehoge (ほげほげ).[6][circular reference] The origin of hoge as a metasyntactic variable is not known, but it is believed to date to the early 1980s.[6]

French[edit]

In France, the word toto is widely used, with variants tata, titi, tutu as related placeholders. One commonly-raised source for the use of toto is a reference to the stock character used to tell jokes with Tête à Toto.[citation needed]

Turkish[edit]

In Turkey, the words hede and hödö (usually spelt hodo due to ASCII-only naming constraints of programming languages) are well-known metasyntactic variables stemmed from popular humorous cartoon magazines of the 90's like LeMan. The words do not mean anything, and specifically used in place of things that do not mean anything. The terms have been popularized to the masses by the actor and stand-up comedian Cem Yılmaz in the late 90's and early 2000's.[7]

Italian[edit]

In the Italian software programming culture, it is common to encounter names of Walt Disney characters being used as variables. These names often appear in pseudo-code, are referenced in Software Engineering classes, and are commonly employed when explaining algorithms to colleagues. Among the most frequently used are "pippo" (Goofy), "pluto," and "paperino" (Donald Duck). [8]

Usage examples[edit]

A screenshot of a metasyntactic variable FOO assigned and echoed in an interactive shell session.

C[edit]

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;
}

C++[edit]

Function prototypes with examples of different argument passing mechanisms:[9]

void Foo(Fruit bar);
void Foo(Fruit* bar);
void Foo(const Fruit& bar);

Example showing the function overloading capabilities of the C++ language

void Foo(int bar);
void Foo(int bar, int baz);
void Foo(int bar, int baz, int qux);

Python[edit]

Spam, ham, and eggs are the principal metasyntactic variables used in the Python programming language.[10] This is a reference to the famous comedy sketch, "Spam", by Monty Python, the eponym of the language.[11] 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

IETF Requests for Comments[edit]

Both the IETF RFCs and computer programming languages are rendered in plain text, making it necessary to distinguish metasyntactic variables by a naming convention, since it would not be obvious from context.

Here is an example from the official IETF document explaining the e-mail protocols (from RFC 772 - cited in RFC 3092):

 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 variables in programming languages. These are specific names from a program, so @code is correct for them."[12])

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

Example data[edit]

SQL[edit]

It is common to use the name ACME in example SQL Databases and as placeholder company-name for the purpose of teaching. The term 'ACME Database' is commonly used to mean a training or example-only set of database data used solely for training or testing. ACME is also commonly used in documentation which shows SQL usage examples, a common practice with in many educational texts as well as technical documentation from companies such as Microsoft and Oracle.[14][15][16]

See also[edit]

References[edit]

  1. ^ a b c Eastlake 3rd, Donald E.; Manros, Carl-Uno; Raymond, Eric S. Etymology of "Foo". doi:10.17487/RFC3092. RFC 3092.
  2. ^ "Document Retrieval". RFC Editor.
  3. ^ Laughlin, Stuart (November 18, 2016). "Metasyntactic variable". programming@ProgClub (Mailing list). Archived from the original on December 2, 2022. Retrieved November 18, 2016.
  4. ^ Crowther, Will (1977-03-11). "advdat.77-03-11". Colossal Cave Adventure Source Code. Dennis G. Jerz. Retrieved 2024-02-28.
  5. ^ "hogeの意味・使い方 - 英和辞典 Weblio 辞書". ejje.weblio.jp.
  6. ^ a b メタ構文変数 (in Japanese)
  7. ^ LeMan Dergisi 1376. Sayı (in Turkish). Lm Basin Yayin Ltd.şti.
  8. ^ "The Jargon File - metasyntactic variable". www.catb.org/.
  9. ^ Mongan, John; Kindler, Noah; Giguere, Eric (2012). Programming Interviews Exposed: Secrets to Landing Your Next Job. John Wiley & Sons. p. 242. ISBN 978-1-118-28720-0.
  10. ^ "The Python Tutorial — Python 3.8.1 documentation". docs.python.org.
  11. ^ "General Python FAQ — Python 3.9.7 documentation". docs.python.org. Python Software Foundation. 2021-09-04. Why is it called Python?. Archived from the original on 2021-08-26. Retrieved 2021-09-05.
  12. ^ "Marking Words and Phrases". Texinfo 4.0. The GNU Documentation Format. Archived from the original on 2009-11-06. Retrieved 2012-11-25.
  13. ^ R. D. Tennent (2002). Specifying Software: A Hands-On Introduction. Cambridge University Press. pp. 36–37 and 210. ISBN 978-0-521-00401-5.
  14. ^ Kriegel, Alex (2008). SQL bible. Indianapolis, Ind: Wiley. ISBN 978-0-470-22906-4. OCLC 402446308.
  15. ^ Ruel, Chris (2014). Oracle 12c for dummies (in Danish). Hoboken, NJ: John Wiley & Sons. ISBN 978-1-118-74531-1. OCLC 870334544.
  16. ^ "Work with data in ASP.NET Core Apps". docs.microsoft.com.

External links[edit]