Cómo utilizar la variable de lista de tokens de \prop_get

Cómo utilizar la variable de lista de tokens de \prop_get

Aquí hay un MWE. Utilizo una lista de tokens y puedo obtener el 10 y octubre en el archivo pdf final.

\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\tl_new:N \l_my_tl
\prop_new:N \l_my_prop

\NewDocumentCommand{\myset}{m}
{
    \tl_set:Nn \l_my_tl { #1 }
    \prop_put:Nnn \l_my_prop {test} {#1}
}

\NewDocumentCommand{\myget}{}
{
     \tl_use:N \l_my_tl
%%% comment out the above line and uncomment the below lines
%     \prop_get:NnN \l_my_prop {test} \l_tmpa_tl
%     \tl_use:N \l_tmpa_tl
}

\ExplSyntaxOff

\newcommand\MonthName[1]{%
  \ifcase#1\relax\or
  January \or Feburary \or March
  \or April \or May \or June
  \or July \or August \or September
  \or October \or November \or December
  \else#1\fi
}
\myset{10}
\begin{document}
\myget\\
\MonthName{\myget}
\end{document}

Luego, si cambio a la lista de accesorios (como dice el comentario), es decir,

\NewDocumentCommand{\myget}{}
{
     \prop_get:NnN \l_my_prop {test} \l_tmpa_tl
     \tl_use:N \l_tmpa_tl
}

se informa un error para\MonthName{\myget}

! Missing number, treated as zero.

\prop_getrecupera el valor almacenado con la clave testde la lista de propiedades \l_my_propy lo coloca en la variable de la lista de tokens \l_tmpa_tl. Y uso esta variable. En comparación con el primer caso, creo que tiene algo que ver \prop_get. Pero no sé cómo solucionarlo.

Respuesta1

\prop_get:NnNno es ampliable, por lo que no se puede utilizar directamente en \ifcase. Cuando \ifcaseintenta expandirse \myget(que no es expandible debido a \prop_get:NnN) falla y TeX dice Missing number, treated as zero.

Sin embargo, la tarea que está realizando \l_tmpa_tles básicamente inútil, por lo que puede omitir ese paso y usar \prop_item:Nndirectamente, que es expandible y hacerlo \mygetexpandible con \NewExpandableDocumentCommand:

\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\tl_new:N \l_my_tl
\prop_new:N \l_my_prop

\NewDocumentCommand{\myset}{m}
{
    \tl_set:Nn \l_my_tl { #1 }
    \prop_put:Nnn \l_my_prop {test} {#1}
}

\NewExpandableDocumentCommand{\myget}{}
{
     % \tl_use:N \l_my_tl
%%% comment out the above line and uncomment the below lines
    \prop_item:Nn \l_my_prop {test}
}

\ExplSyntaxOff

\newcommand\MonthName[1]{%
  \ifcase#1\relax\or
  January \or Feburary \or March
  \or April \or May \or June
  \or July \or August \or September
  \or October \or November \or December
  \else#1\fi
}
\myset{10}
\begin{document}
\myget\\
\MonthName{\myget}
\end{document}

Puedes usar más expl3-y \int_case:nntambién:

\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\tl_new:N \l_my_tl
\prop_new:N \l_my_prop

\NewDocumentCommand{\myset}{m}
  {
    \tl_set:Nn \l_my_tl { #1 }
    \prop_put:Nnn \l_my_prop {test} {#1}
  }

\NewExpandableDocumentCommand{\myget}{}
  {
    \prop_item:Nn \l_my_prop {test}
  }
\NewExpandableDocumentCommand{\MonthName}{m}
  {
    \int_case:nnF { #1 }
      {
        {  1 } { January }
        {  2 } { Feburary }
        {  3 } { March }
        {  4 } { April }
        {  5 } { May }
        {  6 } { June }
        {  7 } { July }
        {  8 } { August }
        {  9 } { September }
        { 10 } { October }
        { 11 } { November }
        { 12 } { December }
      }
      { \int_eval:n {#1} }
  }

\ExplSyntaxOff

\myset{10}
\begin{document}
\myget\\
\MonthName{\myget}
\end{document}

información relacionada