blefloch / latex-unravel

Watching TeX digest tokens
24 stars 1 forks source link

Handle `\relax` without printing `\exp_not:N` #31

Closed Skillmon closed 5 years ago

Skillmon commented 5 years ago

When I try to do

\documentclass{article}
\usepackage{unravel}
\begin{document}
\unravel{\if\relax\detokenize{}\relax\fi}
\end{document}

unravel inserts \exp_not:N in the list of tokens waiting to be used:

[===== Step 5 =====] \exp_not:N \relax 
|| \if \exp_not:N \relax \exp_not:N \relax 
|> \fi
Skillmon commented 5 years ago

Same is true for any detokenized tokens, they all seem to become \exp_not:N ... in printout.

blefloch commented 5 years ago

I haven't checked right now, so the following is from memory. I think unravel will correctly continue the expansion, only the display is affected by this bug. It has nothing to do with \detokenize and everything to do with \if. Anything after \if or \ifcat is prefixed by \exp_not:N (another name for the TeX primitive \noexpand). This was originally because when actually performing the test to compare \foo and \bar one needs to run \if\noexpand\foo\noexpand\bar. I think the infrastructure now allows the displayed tokens to be different from the tokens unravel has in its memory, so this is fixable without too much pain now, but I may be misremembering.

Skillmon commented 5 years ago

Those were just the first two cases in which I encountered the additional \exp_not:N. It doesn't bother me too much (as I know a bit off L3, I know what \exp_not:N is) but I can imagine others might be confused (because of the structure of the macro name, etc.).