9

In the code below, why does the space character not produce an 'Undefined control sequence' error as the dot character does:

\catcode` =\active
\catcode`.=\active
a b
a.b
\bye
9

From plain.tex, lines 524–525:

\def\obeyspaces{\catcode`\ \active}
{\obeyspaces\global\let =\space}

Thus active space has a definition in Plain TeX; why is that? If a space ends up in a token list for \write when \obeyspaces is in force, it will be stored (as active character) to be expanded later, when possibly (or perhaps almost certainly), the declaration is not in force any more. If the definition of the active space is given just locally, such a token in a \write would cause an error for “Undefined control sequence”.

There is another reason (admittedly more obscure): if you do \catcode`\ =12, the declaration

\mathcode`\ ="8000 % \space

on line 86 would come into effect; a space in math mode would then be considered as an active character; but the expansion being a normal space token, it would get ignored nonetheless.

ASCII EOL (^^M) has a similar treatment: lines 521–523 are

{\catcode`\^^M=\active % these lines must end with %
  \gdef\obeylines{\catcode`\^^M\active \let^^M\par}%
  \global\let^^M\par} % this is in case ^^M appears in a \write
8

You have made the chars active but not provided any definitions. As such, you are relying on whatever is 'lying around'. Active space does have a definition, but active . does not so you get an error. You can \show this:

\catcode`\ =\active
\catcode`\.=\active
\show %
\show.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.