Print

Print


Hello again,

Having some more troubles, this time with \token_if_expandable. Here's  
the code:

% \begin{macro}{\token_if_expandable_p:N}
% \begin{macro}[TF]{\token_if_expandable:N}
%   Check if token is expandable. We use the fact that \TeX\ will
%   temporarily convert "\exp_not:N" \m{token} into "\scan_stop:" if
%   \m{token} is expandable.
%    \begin{macrocode}
\def_new:Npn \token_if_expandable_p:N #1{
   \exp_after:NN \if_token_eq:NN \exp_not:N #1 \scan_stop:
     \c_true
   \else:
     \c_false
   \fi:
}
\def_test_function_new:npn {token_if_expandable:N} #1{
   \if:w\token_if_expandable_p:N#1}
%    \end{macrocode}
% \end{macro}
% \end{macro}

Unfortunately, the only token I can find that trips this "true" is  
\relax or \scan_stop:, which isn't exactly what I thought the intended  
behaviour was supposed to be.

   \token_if_expandable:NTF \relax {T}{F}

Ideally, I'd like to be able to write  \def\foo{bar}  and know whether  
or not \foo is expandable; until reading about this test I didn't  
think such a thing was even possible.

Any comments?

Thanks,
Will