Here is something I don't understand about \futurelet
, in this case, into macro \xfl
. I can successfully do the archetypal test of
\ifx\xfl x...
to test whether the next token is an x
. When true, this would indicate that \xfl
replaces to an x
. And yet, if I do a
\detokenize\expandafter{\xfl}
I do not get an x
as I would expect, but only an unexpandable \xfl
.
Why is that? Are there other tests I can perform than \ifx
on a \futurelet
ted token? Can't I truly capture (and save) that token?
\documentclass{article}
\usepackage[T1]{fontenc}
\def\fltest{\futurelet\xfl\pdecide}
\def\pdecide{%
\ifx\xfl x\relax[Next character is x]\else[Not x]\fi\par
(Can't detokenize\detokenize\expandafter{\xfl})\par
}
\begin{document}
\fltest xyz
\end{document}
Where I would really like to end up is to be able to take the token which has been \futurelet
ted and pass it as an argument to a \readlist
. But this code hangs:
\documentclass{article}
\usepackage{listofitems}
\def\fltest{\futurelet\xfl\pdecide}
\def\pdecide{%
\setsepchar{x}% SEARCH FOR x IN NEXT LIST
\readlist\mylist{\xfl}\listlen\mylist[]:
}
\begin{document}
\fltest xyz
\end{document}
Note: siracusa rightly notes that \xfl
doesn't replace with x
, it is x
. Nonetheless, there are things I can do with x
that I cannot do with \xfl
. For example, I can `x to get the ascii value of x
, but cannot do a `\xfl to get the same thing.
\let
or\futurelet
the control sequence is basically the same thing as the following token, just with a different name. That's why\ifx
yields the true branch, and that's also why you get\xfl
back when you use it with\expandafter
, because\xfl
already is fully expanded. – siracusa Feb 12 at 3:50\ifx
to probe the quantity? – Steven B. Segletes Feb 12 at 3:53\meaning\xfl
might give you more data about what it has inside. – Manuel Feb 12 at 7:18