I was looking at LamsTeX, an old TeX format, because it has some interesting macros. I found this article about it. In the article we can read
\bitem Many \LaTeX\ difficulties just now being addressed have simply never existed in \LamSTeX{}. For example, there are no such things as `fragile' commands in \LamSTeX{}, and no worries about long |\write|'s and undesired expansions in |\write|'s to auxiliary files (like the |.toc| file). Arbitrarily long literal mode material can split across pages.
So I got interested and made some experiments with LamsTeX. Looking at the .toc auto-generated file I found that LamsTeX saves all control sequences without expansion, like if they were all "protected" using LaTeX or OPmac terminology. This brought me up a question: what's the need of expanding a control sequence before writing it? Wouldn't it be better to simply write it without expansion?
I have looked at other questions related to this argument, but I can't find the answer to this question.
.auxfiles may occur to the time when the sequence is defined in the document body (speaking ofLaTeXright now), but this command is not available then at the time when the auxiliary files is read – Mar 11 '16 at 21:14\thepagebut in general it is true that making things not expand would probably be the default if etex or more memory had been available in 1980s – David Carlisle Mar 11 '16 at 21:22\protectedattaches an extra flag to each control sequence that determines whether it expands in a write, however the clasic latex \protect mechanism makes a command robust via defining\def\foo{\protect\internalfoo},\def\internalfoo{real stuff}so making all commands robust would double the number of csnames used. when latex2e launched in 93 then latex+amsmath left around 50 csnames free in emtex, so using twice as many csnames in the format wasn't an option. – David Carlisle Mar 11 '16 at 21:33\protectcontrol sequence? I mean, it is enough to define the LaTeX writing mechanism so that it does not expand any control sequence (if not necessary). – User Mar 11 '16 at 21:42