diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3fp-symbolic.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3fp-symbolic.dtx | 101 |
1 files changed, 58 insertions, 43 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-symbolic.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-symbolic.dtx index 277ecfabf55..29ac5aa07c8 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-symbolic.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-symbolic.dtx @@ -42,7 +42,7 @@ % }^^A % } % -% \date{Released 2023-10-23} +% \date{Released 2023-11-01} % % \maketitle % @@ -157,8 +157,8 @@ % \begin{macro}[EXP] % {\@@_if_has_symbolic:nTF, \@@_if_has_symbolic_aux:w} % Tests if |#1| contains \cs{s_@@_symbolic} at top-level. This test -% should be precise enough to determine if a given an array contains a -% symbolic expression or only consists in floating points. Used in +% should be precise enough to determine if a given array contains a +% symbolic expression or only consists of floating points. Used in % \cs{@@_exp_after_symbolic_f:nw}. % \begin{macrocode} \cs_new:Npn \@@_if_has_symbolic:nTF #1 @@ -255,9 +255,9 @@ % \@@_&_symbolic_o:ww, % } % \begin{macrocode} -\cs_set:Npn \@@_tmp:w #1#2 +\cs_set_protected:Npn \@@_tmp:w #1#2 { - \cs_new_nopar:cpn + \cs_new:cpn { @@_symbolic_#2_symbolic_o:ww } { \@@_symbolic_binary_o:Nww #1 } \cs_new_eq:cc @@ -277,7 +277,7 @@ % % \subsection{Applying prefix functions to expressions} % -% \begin{macro}[aux, EXP]{\@@_symbolic_unary_o:NNw} +% \begin{macro}[EXP]{\@@_symbolic_unary_o:NNw} % Used when applying infix operators to expressions. % \begin{macrocode} \cs_new:Npn \@@_symbolic_unary_o:NNw #1#2#3; @ @@ -313,7 +313,7 @@ {not} {sec} {set_sign} {sin} {sqrt} {tan} } { - \cs_new_nopar:cpe { @@_symbolic_#1_o:w } + \cs_new:cpe { @@_symbolic_#1_o:w } { \exp_not:N \@@_symbolic_unary_o:NNw \exp_not:c { @@_#1_o:w } @@ -336,7 +336,7 @@ % \begin{macrocode} \cs_set_protected:Npn \@@_tmp:w #1#2#3 { - \cs_new_nopar:cpn { @@_symbolic_to_#1:w } + \cs_new:cpn { @@_symbolic_to_#1:w } { \exp_after:wN \@@_symbolic_convert:wnnN \exp:w \exp_end_continue_f:w @@ -384,7 +384,8 @@ % \begin{macro}[rEXP] % { % \@@_symbolic_unary_to_tl:NNw, -% \@@_symbolic_binary_to_tl:Nww +% \@@_symbolic_binary_to_tl:Nww, +% \@@_symbolic_function_to_tl:Nw % } % Converting a symbolic expression to a token list is possible. % \begin{macrocode} @@ -440,6 +441,7 @@ % loop through letters in |#1|: if it is not a letter, break the loop % and return \texttt{true}. If the end of the loop is reached % without finding any non-letter, return \texttt{false}. +% Note |#1| must be a str (i.e., resulted from \cs{tl_to_str:n}). % \begin{macrocode} \prg_new_protected_conditional:Npnn \@@_id_if_invalid:n #1 { T , F , TF } @@ -447,10 +449,10 @@ \tl_if_empty:nTF {#1} { \prg_return_true: } { - \tl_if_in:onTF { \tl_to_str:n {#1} } { ~ } + \tl_if_in:nnTF { #1 } { ~ } { \prg_return_true: } { - \exp_after:wN \@@_id_if_invalid_aux:N \tl_to_str:n {#1} + \@@_id_if_invalid_aux:N #1 { ? \prg_break:n \prg_return_false: } \prg_break_point: } @@ -511,9 +513,9 @@ % \begin{macro} % {\@@_variable_set_parsing:Nn, \@@_variable_set_parsing_aux:NNn} % \begin{macrocode} -\cs_new:Npn \@@_variable_set_parsing:Nn #1#2 +\cs_new_protected:Npn \@@_variable_set_parsing:Nn #1#2 { - \cs_set_nopar:Npn \@@_tmp:w + \cs_set:Npn \@@_tmp:w { \@@_exp_after_symbolic_f:nw { \@@_parse_infix:NN } \s_@@_symbolic \@@_symbolic_chk:w @@ -522,7 +524,7 @@ \exp_args:NNc \@@_variable_set_parsing_aux:NNn #1 { @@_parse_word_#2:N } {#2} } -\cs_new:Npn \@@_variable_set_parsing_aux:NNn #1#2#3 +\cs_new_protected:Npn \@@_variable_set_parsing_aux:NNn #1#2#3 { \cs_if_eq:NNF #2 \@@_tmp:w { @@ -541,23 +543,32 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\fp_clear_variable:n} -% \begin{macro}{\@@_clear_variable:n} +% \begin{macro} +% { +% \fp_clear_variable:n, +% \@@_clear_variable:n, \@@_clear_variable_aux:n +% } +% We need local undefining, so have to do it low-level. +% \cs{@@_clear_variable_aux:n} is needed by \cs{@@_set_function:Nnnn} +% to skip \cs{@@_id_if_invalid:nTF}. % \begin{macrocode} \cs_new_protected:Npn \fp_clear_variable:n #1 { + \exp_args:No \@@_clear_variable:n { \tl_to_str:n {#1} } + } +\cs_new_protected:Npn \@@_clear_variable:n #1 + { \@@_id_if_invalid:nTF {#1} { \msg_error:nnn { fp } { id-invalid } {#1} } - { \exp_args:No \@@_clear_variable:n { \tl_to_str:n {#1} } } + { \@@_clear_variable_aux:n {#1} } } -\cs_new_protected:Npn \@@_clear_variable:n #1 +\cs_new_protected:Npn \@@_clear_variable_aux:n #1 { - \cs_undefine:c { l_@@_variable_#1_fp } + \cs_set_eq:cN { l_@@_variable_#1_fp } \tex_undefined:D \@@_variable_set_parsing:Nn \cs_set_eq:NN {#1} } % \end{macrocode} % \end{macro} -% \end{macro} % % \begin{macro}{\fp_new_variable:n} % \begin{macro}{\@@_new_variable:n} @@ -567,20 +578,22 @@ % \begin{macrocode} \cs_new_protected:Npn \fp_new_variable:n #1 { - \@@_id_if_invalid:nTF {#1} - { \msg_error:nnn { fp } { id-invalid } {#1} } - { \exp_args:No \@@_new_variable:n { \tl_to_str:n {#1} } } + \exp_args:No \@@_new_variable:n { \tl_to_str:n {#1} } } \cs_new_protected:Npn \@@_new_variable:n #1 { - \cs_if_exist:cT { @@_parse_word_#1:N } + \@@_id_if_invalid:nTF {#1} + { \msg_error:nnn { fp } { id-invalid } {#1} } { - \msg_error:nnn - { fp } { id-already-defined } {#1} - \cs_undefine:c { @@_parse_word_#1:N } - \cs_undefine:c { l_@@_variable_#1_fp } + \cs_if_exist:cT { @@_parse_word_#1:N } + { + \msg_error:nnn + { fp } { id-already-defined } {#1} + \cs_undefine:c { @@_parse_word_#1:N } + \cs_set_eq:cN { l_@@_variable_#1_fp } \tex_undefined:D + } + \@@_variable_set_parsing:Nn \cs_gset_eq:NN {#1} } - \@@_variable_set_parsing:Nn \cs_gset_eq:NN {#1} } % \end{macrocode} % \end{macro} @@ -605,24 +618,26 @@ \flag_new:n { @@_symbolic } \cs_new_protected:Npn \fp_set_variable:nn #1 { - \@@_id_if_invalid:nTF {#1} - { \msg_error:nnn { fp } { id-invalid } {#1} } - { \exp_args:No \@@_set_variable:nn { \tl_to_str:n {#1} } } + \exp_args:No \@@_set_variable:nn { \tl_to_str:n {#1} } } \cs_new_protected:Npn \@@_set_variable:nn #1#2 { - \@@_variable_set_parsing:Nn \cs_set_eq:NN {#1} - \fp_set:Nn \l_@@_symbolic_fp {#2} - \cs_set_nopar:cpn { l_@@_variable_#1_fp } - { \flag_ensure_raised:n { @@_symbolic } \c_nan_fp } - \flag_clear:n { @@_symbolic } - \fp_set:cn { l_@@_variable_#1_fp } { \l_@@_symbolic_fp } - \flag_if_raised:nT { @@_symbolic } + \@@_id_if_invalid:nTF {#1} + { \msg_error:nnn { fp } { id-invalid } {#1} } { - \msg_error:nneee { fp } { id-loop } - { \tl_to_str:n {#1} } - { \tl_to_str:n {#2} } - { \fp_to_tl:N \l_@@_symbolic_fp } + \@@_variable_set_parsing:Nn \cs_set_eq:NN {#1} + \fp_set:Nn \l_@@_symbolic_fp {#2} + \cs_set_nopar:cpn { l_@@_variable_#1_fp } + { \flag_ensure_raised:n { @@_symbolic } \c_nan_fp } + \flag_clear:n { @@_symbolic } + \fp_set:cn { l_@@_variable_#1_fp } { \l_@@_symbolic_fp } + \flag_if_raised:nT { @@_symbolic } + { + \msg_error:nneee { fp } { id-loop } + { #1 } + { \tl_to_str:n {#2} } + { \fp_to_tl:N \l_@@_symbolic_fp } + } } } % \end{macrocode} |