What is the purpose of a <filler> in TeX's syntax?
Space is perhaps easier to justify as it makes some tex primitives that take braced arguments act a little bit more like macros where \frac {1} {2}
the space token before the second brace is ignored. It is also why spaces after =
in \count0 = 2
are ignored, however in both cases there are perhaps more natural places in the grammar where spaces could have been absorbed.
\relax
is harder to justify but I would guess it is for
\insert <8 bit number> <filler> {...}
where it means that if you have a habit or a macro that always terminates numbers with \relax
you can have
\insert 250\relax {...}
But to be honest it mostly looks like an early syntax idea from the start of the TeX design that doesn't really make sense the way TeX finally came out.
Quite often the tex source (tex.web
) is more informative than the texbook for this sort of thing but the word filler
does not appear and all it says that I can see is
@ The |scan_left_brace| routine is called when a left brace is supposed to be
the next non-blank token. (The term ``left brace'' means, more precisely,
a character whose catcode is |left_brace|.) \TeX\ allows \.{\\relax} to
appear before the |left_brace|.
which doesn't give much of a clue as to why \relax
is allowed.
The grammar given in The TeXbook documents what the program (TeX) does, rather than the program being written to match a specific grammar. (Although I can't definitively prove this, this is fairly clear (IMO) from looking at both; also consider these stories.) So as pointed out by David Carlisle's answer, the relevant part seems to be scan_left_brace
in the TeX program's source code (available as a book, with texdoc tex
, or online):
So your question seems to boil down to why scan_left_brace
(as called from scan_toks
, which is called when acting on \uppercase
etc.) ignores both spaces and \relax
tokens. Some clues are available in TeX's change log (available with texdoc errorlog
or online) (to make sense of it see also Notes on the Errors of TeX and the paper The Errors of TeX, reprinted with additions and corrections as Chapters 10 and 11 of Literate Programming). If you look for the relevant sections 403 and 404, you see:
[19 May 1978] Change 251 [Algorithmic Anomaly]. Skip past blanks in the
scan_math
procedure. [This blank-skipping will eventually go intoscan_left_brace
.] [Affects §403.][5 Mar 1981] Change 498 [Cleanup for Consistency]. Allow optional space before a required left brace, e.g.,
\if AA {...}
. [See Change 251.] [Affects §403.][28 May 1983] Change 699 [Cleanup for Consistency]. Ignore ‘
\relax
’ as if it were a space, in math mode and in a few other places where\relax
would otherwise be erroneous. [Affects §404.]
(FWIW, The TeXbook's preface is dated June 1983; it was first published in 1984.)
I think this may give some clue towards the question (if I understood it). At least for spaces, there are many examples for which it makes sense. When it comes to \relax
, note that just like the §404 "Get the next non-blank non-relax non-call token" there's another §406 "Get the next non-blank non-call token" where \relax
is not ignored, and it's used in another bunch of places (like scan_optional_equals
). So you might ask why each of those places chooses to ignore \relax
rather than not, and it may be hard (for me) to explain each of those choices (though it must have been a conscious choice as it would have been so easy to choose otherwise).