A metasyntactic variable is a word or term that stands in for something else, typically used when you're describing an overall pattern, and the subject under discussion could have any name in actual practice. A placeholder.
It's most commonly used in computer science and related fields, and in that community foo is the most commonly used and recognized metasyntactic variable.
The classic example from the C2 Wiki:
Suppose I have a list, foo, with a node, bar, ...
What this allows us to do is now refer to the list as "foo" and and the node as "bar", as in "now, if bar is the last node in foo...", while recognizing that in a program the real "foo" and "bar" could have any name at all.
But here, I'm not asking about "foo" or "bar"¹ or any specific metasyntactic variable, I'm asking about the term metasyntactic variable.
A recent answer on a different question suggested the author Terry Pratchett could have invented it:
Terry Pratchett .. used the idea of a 'Metasyntactic variable' (his own nomenclature I believe but open to correction).
Pratchett didn't invent the term, but the answer prompted me to look into who did, and I'm stumped.
- When was the term metasyntactic variable first used, or metasyntactic modifying some other word, giving the same meaning?
- Why meta-syntactic?
- Was there any specific event or author who popularized it, or was its growth simply organic?
- Is the term used with the same meaning in any interesting ways outside of the software world (like the Terry Pratchett example)?
Using Google Books and Google nGrams², the earliest use of the full term metasyntactic variable I could find was the 1979 work The MDL Programming Language, which reads, on page 4:
A metasyntactic variable -- something to be replaced in actual use by something else -- appears as a radix:fix, in an italic font; often the variable will have both a meaning and a data type (as here), but sometimes those will be omitted, for obvious reasons.
and on page 44:
TYPE (aren't homonyms wonderful?), just type the appropriate ATOM, like FIX or FLOAT or ATOM etc. However, in this document we will use the convention that a metasyntactic variable can have a type for a "data type": for example, foo:type means that the TYPE of foo is ATOM, but the ATOM must be something that the SUBR TYPE can return.
These paragraphs suggest, respectively, that (a) the term is new enough that it has to be defined (a 1990 Emacs Lisp manual uses the word unselfconsicously and without any definition, because by then everyone knew what it meant), and (b) that it's established enough that the authors have to defend their novel convention that m.v.s may have data types (which is atypical).
Which means this may be an early use, but not the first use.
So, broadening my search, and looking for only metasyntactic, I found ALGOL-Bulletin no. 13, published August 1961, mentioning a memo written in November 1960 which used that word:
But it's not clear whether this metasyntactic had the same sense as it does in the full term metasyntactic variable, as the word "classes" suggest this might be a more specific and technical term of art in ALGOL's design, or computer language design more broadly.
Aside from its first use, I'm interested in why the term "metasyntactic" was chosen in the first place. What is "meta" about these terms' relationship to syntax?
The canonical source on this, The Jargon File, presents three different concepts (list-ified for clarity):
Metasyntactic variables are so called because
1. They are variables in the metalanguage used to talk about programs etc.
2. 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”).
3. However, it has been plausibly suggested that the real reason for the term “metasyntactic variable” is that it sounds good.
In addition, I've personally made the argument that their meta-syntacticness arises from the fact that the same words can be used to stand in for any part of speech.
In any case, while (1) or some version of it is probably the first idea that would come to most people's minds, the fact that the Jargon File didn't stop there is telling, and I think finding the origins of the term will shed a lot of light here.
Non-software uses or origins
The Terry Pratchett answer above also got me thinking: do non-computer scientists use the term metasyntactic variable, in a non-software context? Are there people who use this term non-ironically, who are not familiar with its software sense?
I would be particularly interested in answers which show the term pre-dates its use in software. Given that "syntax" is really only studied by one other group, I wonder do linguists or syntacticians of natural languages³ use this term at all? Did they do so before, say, 1950?
¹ Interestingly, foo and bar have their own, detailed etymology, and no, it's not as straightforward as "arising from the WWII acronym FUBAR". See RFC 3092 and the canonical post about foo here on EL&U.
² I actually was forced to use only Google Books for the full term; for some reason, metasyntactic variable doesn't show up in nGram Viewer at all.
³ I once made the case that words like "thingy", "doodad", "whatshisface", etc are "metasyntactic variables", but John Lawler says they're more properly termed "nonce forms" by linguists.
PS: I know I've picked the low-hanging fruit here, with Google Books and Google nGram Viewer, but I would really still prefer scholastic, detailed answers. Speculation will just add noise. Though I'm also happy to accept first-hand accounts from people who lived through the 50s-60s-70s computer era (or very credible second-hand accounts).