Hello,
[...]
% Now this is weird: First doubled, then not \edef\foo{\the\expandafter\toks@\the\toks@}
\the\toks@ passes # unmolested into \edef. In every other case (apart from the equivalent use of \unexpanded), a doubled ## is required for producing a single # in the result, because then # is a parameter delimiting token for the \edef. The \expandafter takes the ## out of the token register and into the regular input stream, so the #-preserving character of \the inside of \edef is no longer in action.
You are of course right. And I am a little bit wiser.
[...]
And it might be useful too, to build up the body of a complicated macro inside a \toks register before finally creating the macro using \edef:
What do you think?
You are about 20 years late. Please check LaTeX's definition (and usage) of \g@addto@macro: [...]
Well, my example was to show how to use above behaviour to create the body of a macro *with parameters* in a \toks register. \g@addto@macro does not do this.
David Kastrup
Jonathan