Hello List,
I am trying to understand the expl3 conventions by looking at its source
files. However, I am not sure what the final code that is placed
into the input stream by the following function (copied from
`expl3-code.tex', 2018-12-12) is:
\use:x
{
\prg_new_conditional:Npnn \exp_not:N \token_if_macro:N ##1
{ p , T , F , TF }
{
\exp_not:N \exp_after:wN \exp_not:N \__token_if_macro_p:w
\exp_not:N \token_to_meaning:N ##1 \tl_to_str:n { ma : }
\exp_not:N \q_stop
}
\cs_new:Npn \exp_not:N \__token_if_macro_p:w
##1 \tl_to_str:n { ma } ##2 \c_colon_str ##3 \exp_not:N \q_stop
}
{
\str_if_eq:nnTF { #2 } { cro }
{ \prg_return_true: }
{ \prg_return_false: }
}
As I understand, after the first level of expansion it becomes:
\prg_new_conditional:Npnn \token_if_macro:N #1 % Line 1
{ p , T , F , TF } % Line 2
{ % Line 3
\exp_after:wN \__token_if_macro_p:w % Line 4
\token_to_meaning:N #1 ma: % Line 5
\q_stop % Line 6
} % Line 7
\cs_new:Npn \__token_if_macro_p:w % Line 8
#1 ma #2 : #3 \q_stop % Line 9
{ % Line 10
\str_if_eq:nnTF { #2 } { cro } % Line 11
{ \prg_return_true: } % Line 12
{ \prg_return_false: } % Line 13
}
The category codes of all characters in ma: (in line 5),
ma (in line 9), and : (in line 9) are 12.
Now let's suppose that the arguments are
\aaa whose meaning is "zzz", bbb, and x respectively.
So, after the second level of expansion, I think the
following piece of code is placed into the input stream:
\prg_new_conditional:Npnn \token_if_macro:N \aaa % Line 1
{ p , T , F , TF } % Line 2
{ % Line 3
\__token_if_macro_p:w % Line 4
zzzma: % Line 5
% Line 6
} % Line 7
\cs_new:Npn \__token_if_macro_p:w % Line 8
zzzmabbb:x % Line 9
{ % Line 10
\str_if_eq:nnTF { bbb } { cro } % Line 11
{ \prg_return_true: } % Line 12
{ \prg_return_false: } % Line 13
}
Shouldn't the token "\aaa" in Line 1 and zzz in
line 5 and 9 be replaced with "#1", because the function
\prg_new_conditional:Npnn expects a parameter to be there?
Also, I am not quite sure about the expansion in Line 9.
Any help would be gratefully appreciated.
Thanks,
Tisha
|