[texhax] Some puzzling TeX
Donald Arseneau
asnd at triumf.ca
Tue Feb 22 13:24:54 CET 2011
"Uwe Lueck" <uwe.lueck at web.de> writes:
> >On Sun, Feb 20, 2011 at 8:13 AM, Uwe Lueck wrote:
> >> I am unable to get a catcode of \relax or \bgroup by \showthe\catcode.
This betrays a subtle misunderstanding. There is no catcode of
\relax; only character tokens have category codes. \bgroup is
let equal to a character token so it does indeed have a category
code (1).
However \catcode does not tell the category of a character token!
It only reports contents of the look-up table TeX uses to interpret
raw characters as they are input (or as they are re-scanned, in eTeX).
This has to be so since the argument for \catcode is a number, not
a token!
Therefore the concept of "get a catcode of" some token, any token,
by \showthe\catcode is without hope.
TeX provides no way to report the category code for a token except
by a deeply nested series of \ifcat comparisons.
> >> Only with \ifcat, I can see that \relax and \bgroup are different,
> >> while, e.g., after \let\BGROUP{\et\EGROUP}, \bgroup and \BGROUP
> >> are the same according to \ifcat.
Yes.
> >> My conclusion at the moment is that one might better say that
> >> with \ifcat, control sequences behave "as if they had catcode 16 or ..."
> >> Especially, it seems to me that instead of "catcode 16" one could
> >> as well speak of "catcode -1" or anything else that is not among
> >> 0, ..., 15.
I think "TeX considers it to have", as in the TeXbook, gets the meaning
across. Yes, any other out-of-band or impossible value would have served
as well.
> > Whew... so, it looks like this myth of "control sequences have
> > catcode 16" can finally be put to rest. The catcode of a control
> > sequence is, in fact, 0. But since there's no way to ever get a naked
> > escape token (catcode 0) into the input stream, the fact that it has
> > the same catcode is irrelevant.
Interesting. I wonder why DEK says 16 then. Laziness? Simplicity
(avoid explaining why 0 is safe)? Forgetfulness?
--
Donald Arseneau asnd at triumf.ca
More information about the texhax
mailing list