Metasyntactic variables are variables whose values are understood to be pieces of syntax (possibly, the names of other variables, which are syntax). They appear in formulas that operate on syntax, and so are meta-syntax.
For instance, consider S V O
(subject verb object), an expression indicating the basic word order of some human language. These three letters are meta-syntactic variables. Each one denotes some piece of syntax. A sentence subject can be a complex noun phrase, and so on. Moreover, these letters are chosen in a way that is significant in the linguistic problem domain: S
stands for subject, and so forth.
foo
and bar
can be considered metasyntactic in the sense that they serve as place holders for real names that are to be invented by the user. These particular names are meaningful in the problem domain of writing code examples in computer documentation, where they are instantly recognizable, like old friends. So, paradoxically, foo
expresses "I am famous for having no meaning. Wherever you see me, replace me with something which has one!", and that is its meaning.
It is also understood that where both foo
and bar
appear, the user must substitute distinct symbols, and where foo
appears more than once in the same example, all occurrences must be consistently replaced with the same identifier.
foo
and bar
are effective as long as they don't clash with anything in the computer language, such as built-in commands, keywords or the names of significant library functions or variables. If that happens, the syntax and meta-syntax levels become confused. If you're designing a new language, it behooves you to avoid introducing foo
and bar
as significant identifiers in that language.
The words foo and bar have an etymology, but that etymology is not connected to their meaning in computing documentation.
foo
is a term strictly used by programmers and in code, and is hard ever related to computer software and hardware from the user perspective.