"Jonathan Sauer"
[\unexpanded vs \detokenize]
2. \unexpanded introduces spaces after control sequences.
Why wouldn't \detokenize do the same? Wait, it does:
At least in the context of \directlua. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I guess that this may be the real reason.
I thought a bit about this, and I think that it is quite useful if \detokenize does not introduce spaces when used in \directlua, as opposed to \unexpanded, since sometimes (i.e. when used as a set in lpeg.S) spaces are completely undesired.
Of course, in these situations \string could be used as an alternative. But since \detokenize is equivalent (at least as I understand it)
Your understanding is wrong. etex This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6) %&-line parsing enabled. **\message{\detokenize{\x}a} entering extended mode \x a *\message{\string\x a} \xa *\end No pages of output. Transcript written on texput.log.
to prefixing each token with \string, \detokenize should not introduce spaces. IMO.
I disagree. I don't think that \detokenize should behave differently within \directlua. Not least of all since "within" is very fuzzy to define when macro expansion is involved. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum