[tex-k] TeX erranously expands tokens from a token variable
Don Hosek
don.hosek at gmail.com
Mon Aug 9 00:24:51 CEST 2021
On 8 Aug 2021, at 16:49, Karl Berry <karl at freefriends.org> wrote:
>
> \edef\good{\b\the\toks0 \the\toks1}
> \edef\bad{\b\the\toks0\the\toks1}
>
> As far as I can see:
>
> In the \bad case, TeX has to fully expand \the\toks1 tokens in order to
> see if they start with a numeral to follow the 0 in \the\toks0, i.e., to
> determine the \toks register number to expand. This is described
> (tersely/opaquely as usual) in The TeXbook, to my recollection, though I
> didn't try to find it. Am I missing some reason why this is not the case?
No, I would expect that \the\tok1 would get expanded before \the\toks0. I think the TeXbook is pretty clear about what’s going on around numeric constants and has multiple references to it throughout the book and examples. This also part of the reason for defining, e.g., \z@ in plain.tex in that it keeps unexpected things from happening if e.g., someone writes
5,\allowbreak123,\allowbreak123,\allowbreak123,\allowbreak123,\allowbreak123,\allowbreak123,\allowbreak123
(which while it might be a dubious choice typographically is not completely inconceivable).
-dh
More information about the tex-k
mailing list.