Comment by kazinator

Comment by kazinator 16 hours ago

0 replies

Foo and bar are often not metasyntactic at all, and often do not have to be substituted for real use. The only problem would be that they're not good names in the domain where they end up.

A metasyntactic variable is a variable whose value is syntax. This most obviously happens in macro programming. A macro manipulates syntax, and so it is on a meta level. Typical metasyntactic variables in macros are names like expr, var, sym, body, initializer, type, ...

In documentation, metasyntactic variables indicate where information is to be substituted, not alternative naming. For instance: "Your network-wide home directory is found at /nfs/atlas/users/$YOUR_USERID." A file system path is a kind of syntax. Symbolic indications where specific, correct forms are to be substituted from are metasyntactic.

Foo and bar are just example names shown in regular syntax, not in a meta syntax that transforms to regular syntax. Made up example names are not meta. Bob and Alice are not meta!

For instance, "The simplest pattern for a C definition is: <type> <ident> = <initializer>;"

Here those words in angle brackets are metasyntactic variables. The instructional text then continues:

"For example: int foo = 2 + bar".

Here foo and bar are no more metasyntactic than int, + and 2! They are just example material. The act of generating an example from a syntactic pattern is a metasyntactic activity, to be sure. The resulting example is not meta though.

As a rule of thumb, the symbols in anything that resembles a grammar rule are metasyntactic. Symbols in a piece of syntax generated from the grammar are not, or at least not in respect to the language described by that grammar. They are an example of the language.