[Dev-luatex] # or ##, that is the question

David Kastrup dak at gnu.org
Wed Oct 17 15:15:21 CEST 2007

"Jonathan Sauer" <Jonathan.Sauer at silverstroke.com> writes:

>> [...]
>> > % 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 at 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 at addto@macro
> does not do this.

But it can be used for it.  Which is the reason it is implemented
using a token register (according to the change note in ltclass.dtx,
this has been done in 1994, probably due to a somewhat pressing
suggestion of mine, so I have to take back the "20 years").

David Kastrup

More information about the dev-luatex mailing list