Many of TeX's primitives require a <general text>
as their argument (e.g. \uppercase
), which is defined as (TeXbook p. 276)
<general text> -> <filler>{<balanced text><right brace>
where <filler>
is an arbitrary sequence of spaces and \relax
commands. Now I would like to find out in what way it is useful that such a <filler>
can be inserted.
Could someone give an example where the presence or absence of a <filler>
makes any difference, or, if such a situation shouldn't exist, explain why the fact that a <filler>
could be inserted is advantageous?
Edit: In the original version of the question, I claimed that
[...] constructs such as
\uppercase\expandafter{\romannumeral ...
are already made possible by the fact that the left brace may be implicit, so that TeX is expanding to find one.
Thanks to a discussion with frougon, I have come to realize that this is a misunderstanding. Here is what I currently believe to be true:
- TeX really just always expands expandable tokens whenever expansion is not inhibited (i.e., except from the situations in TeXbook p. 215)
\expandafter
is expandable and expansion (immediately) after\uppercase
and the like is not inhibited (only after the opening brace was found), which is the full reason for why expansion takes place in this situation- the syntax rules are not an inherent property of the language that could be found explicitly in
tex.web
; in fact, syntactic correctness (only spaces and\relax
tokens allowed before the{
) matters only once something unexpandable was found
As a consequence:
- the fact that the syntax requires a (possibly empty)
<filler>
and a (possibly implicit) opening brace has nothing to do with whether or not things are expanded - instead, the fact that a
<general text>
allows an implicit brace and\def
requires an explicit one merely emerges from the phenomenon that expansion is inhibited after a\def
, but not before the<balanced text>
of a<general text>
Basically it's not the case that implicit braces in the syntax rules imply expansion, but the other way around: Expansion implies that the braces may be implicit. Also, implicit braces are defined as control sequences that were \let
or \futurelet
to a category 1 token, not just anything expanding to one, so it wouldn't make sense to say that TeX fully expands tokens in order to find a brace as I originally thought.
This does not affect the question itself, though; it just illustrates how I was mistaking the descriptive nature of the grammar rules for a normative one.
\toks0=\csname maybeexpandafter\endcsname{\foo}
. If\maybeexpandafter
is not defined, the\csname
will turn it into\relax
.\relax
inserted by incomplete if constructs but I couldn't think of a plausible looking example where you could generate a relax from an incomplete if token in a filler position:-)