[latex3-commits] [latex3/latex3] conditional-forms: Auto-generate all eq. conditionals in \prg_new_eq_conditional:NNn, etc. (afab06698)
github at latex-project.org
github at latex-project.org
Sat Nov 23 08:32:45 CET 2024
Repository : https://github.com/latex3/latex3
On branch : conditional-forms
Link : https://github.com/latex3/latex3/commit/afab066988ed602a2571849ef20273138dbea039
>---------------------------------------------------------------
commit afab066988ed602a2571849ef20273138dbea039
Author: Joseph Wright <joseph at texdev.net>
Date: Wed Nov 20 09:10:51 2024 +0000
Auto-generate all eq. conditionals in \prg_new_eq_conditional:NNn, etc.
>---------------------------------------------------------------
afab066988ed602a2571849ef20273138dbea039
l3kernel/l3basics.dtx | 40 ++++++++++++++------------------------
l3kernel/l3debug.dtx | 16 +++++++--------
l3kernel/l3prg.dtx | 7 +++----
l3kernel/testfiles/m3basics002.lvt | 4 ++--
l3kernel/testfiles/m3basics002.tlg | 16 ++++++++-------
5 files changed, 37 insertions(+), 46 deletions(-)
diff --git a/l3kernel/l3basics.dtx b/l3kernel/l3basics.dtx
index eb4beda7a..19907e8ba 100644
--- a/l3kernel/l3basics.dtx
+++ b/l3kernel/l3basics.dtx
@@ -2208,7 +2208,7 @@
\cs_split_function:N #2
\cs_split_function:N #3
\exp_not:N #1
- \tl_to_str:n {#4}
+ \tl_to_str:n { T , F , TF , p }
\exp_not:n { , \q_@@_recursion_tail , \q_@@_recursion_stop }
}
}
@@ -2223,10 +2223,10 @@
% }
% \begin{macro}[EXP]
% {
-% \@@_set_eq_conditional_p_form:nnn ,
-% \@@_set_eq_conditional_TF_form:nnn ,
-% \@@_set_eq_conditional_T_form:nnn ,
-% \@@_set_eq_conditional_F_form:nnn ,
+% \@@_set_eq_conditional_p_form:Nnnnn ,
+% \@@_set_eq_conditional_TF_form:Nnnnn ,
+% \@@_set_eq_conditional_T_form:Nnnnn ,
+% \@@_set_eq_conditional_F_form:Nnnnn ,
% }
% Split the function to be defined, and setup a manual clist loop over
% argument |#6| of the first auxiliary. The second auxiliary receives
@@ -2235,9 +2235,7 @@
% contained a colon, otherwise we don't know how to build
% conditionals, hence abort. Call the looping macro, with arguments
% \Arg{name_1} \Arg{signature_1} \Arg{name_2} \Arg{signature_2}
-% \meta{copying~function} and followed by the comma list. At each
-% step in the loop, make sure that the conditional form we copy is
-% defined, and copy it, otherwise abort.
+% \meta{copying~function} and followed by the comma list.
% \begin{macrocode}
\cs_gset_protected:Npn \@@_set_eq_conditional:nnNnnNNw #1#2#3#4#5#6
{
@@ -2258,26 +2256,18 @@
\if_meaning:w \q_@@_recursion_tail #6
\exp_after:wN \@@_use_none_delimit_by_q_recursion_stop:w
\fi:
- \use:c { @@_set_eq_conditional_ #6 _form:wNnnnn }
- \tl_if_empty:nF {#6}
- {
- \msg_error:nnee
- { kernel } { conditional-form-unknown }
- {#6} { \token_to_str:c { #1 : #2 } }
- }
- \use_none:nnnnnn
- \s_@@_stop
+ \use:c { @@_set_eq_conditional_ #6 _form:Nnnnn }
#5 {#1} {#2} {#3} {#4}
\@@_set_eq_conditional_loop:nnnnNw {#1} {#2} {#3} {#4} #5
}
-\cs_gset:Npn \@@_set_eq_conditional_p_form:wNnnnn #1 \s_@@_stop #2#3#4#5#6
- { #2 { #3 _p : #4 } { #5 _p : #6 } }
-\cs_gset:Npn \@@_set_eq_conditional_TF_form:wNnnnn #1 \s_@@_stop #2#3#4#5#6
- { #2 { #3 : #4 TF } { #5 : #6 TF } }
-\cs_gset:Npn \@@_set_eq_conditional_T_form:wNnnnn #1 \s_@@_stop #2#3#4#5#6
- { #2 { #3 : #4 T } { #5 : #6 T } }
-\cs_gset:Npn \@@_set_eq_conditional_F_form:wNnnnn #1 \s_@@_stop #2#3#4#5#6
- { #2 { #3 : #4 F } { #5 : #6 F } }
+\cs_gset:Npn \@@_set_eq_conditional_p_form:Nnnnn #1#2#3#4#5
+ { #1 { #2 _p : #3 } { #4 _p : #5 } }
+\cs_gset:Npn \@@_set_eq_conditional_TF_form:Nnnnn #1#2#3#4#5
+ { #1 { #2 : #3 TF } { #4 : #5 TF } }
+\cs_gset:Npn \@@_set_eq_conditional_T_form:Nnnnn #1#2#3#4#5
+ { #1 { #2 : #3 T } { #4 : #5 T } }
+\cs_gset:Npn \@@_set_eq_conditional_F_form:Nnnnn #1#2#3#4#5
+ { #1 { #2 : #3 F } { #4 : #5 F } }
% \end{macrocode}
% \end{macro}
% \end{macro}
diff --git a/l3kernel/l3debug.dtx b/l3kernel/l3debug.dtx
index c3554aab6..5a83b7cbe 100644
--- a/l3kernel/l3debug.dtx
+++ b/l3kernel/l3debug.dtx
@@ -1021,21 +1021,21 @@
% Internal functions from \pkg{prg} module.
% \begin{macrocode}
\__kernel_patch_weird:nnn
- { \__kernel_chk_cs_exist:c { #5 _p : #6 } }
+ { \__kernel_chk_cs_exist:c { #4 _p : #5 } }
{ }
- { \@@_set_eq_conditional_p_form:wNnnnn }
+ { \@@_set_eq_conditional_p_form:Nnnnn }
\__kernel_patch_weird:nnn
- { \__kernel_chk_cs_exist:c { #5 : #6 TF } }
+ { \__kernel_chk_cs_exist:c { #4 : #5 TF } }
{ }
- { \@@_set_eq_conditional_TF_form:wNnnnn }
+ { \@@_set_eq_conditional_TF_form:Nnnnn }
\__kernel_patch_weird:nnn
- { \__kernel_chk_cs_exist:c { #5 : #6 T } }
+ { \__kernel_chk_cs_exist:c { #4 : #5 T } }
{ }
- { \@@_set_eq_conditional_T_form:wNnnnn }
+ { \@@_set_eq_conditional_T_form:Nnnnn }
\__kernel_patch_weird:nnn
- { \__kernel_chk_cs_exist:c { #5 : #6 F } }
+ { \__kernel_chk_cs_exist:c { #4 : #5 F } }
{ }
- { \@@_set_eq_conditional_F_form:wNnnnn }
+ { \@@_set_eq_conditional_F_form:Nnnnn }
% \end{macrocode}
%
% \begin{macrocode}
diff --git a/l3kernel/l3prg.dtx b/l3kernel/l3prg.dtx
index 24c5f90d0..49352ae32 100644
--- a/l3kernel/l3prg.dtx
+++ b/l3kernel/l3prg.dtx
@@ -173,7 +173,7 @@
% \cs{prg_return_true:} \cs{else:} \cs{prg_return_false:} \cs{fi:} is
% optimized.
%
-% \begin{function}[updated = 2023-05-26]
+% \begin{function}[updated = 2024-11-20]
% {
% \prg_new_eq_conditional:NNn,
% \prg_set_eq_conditional:NNn,
@@ -185,9 +185,8 @@
% These functions copy a family of conditionals. The \texttt{new} version
% checks for existing definitions (\emph{cf.}~\cs{cs_new_eq:NN}) whereas
% the \texttt{set} version does not (\emph{cf.}~\cs{cs_set_eq:NN}). The
-% conditionals copied are depended on the comma-separated list of
-% \meta{conditions}, which should be one or more of \texttt{p}, \texttt{T},
-% \texttt{F} and \texttt{TF}.
+% \Arg{conditions} argument is purely a reminder to the programmer:
+% all of the |T|, |F|, |TF| and |p| forms will set up.
% \end{function}
%
% \begin{function}[EXP]{\prg_return_true:, \prg_return_false:}
diff --git a/l3kernel/testfiles/m3basics002.lvt b/l3kernel/testfiles/m3basics002.lvt
index 8d83d15db..10cedf463 100644
--- a/l3kernel/testfiles/m3basics002.lvt
+++ b/l3kernel/testfiles/m3basics002.lvt
@@ -96,7 +96,7 @@
\cs_log:N \bar:nnnT
\cs_log:N \bar:nnnF
\prg_new_eq_conditional:NNn \bar:n \tl_if_empty:n { TF }
- \cs_if_eq:NNF \bar:nTF \tl_if_empty:nTF { \ERROR }
+ \cs_if_eq:NNF \bar:nTF \tl_if_empty:nTF { \TRUE }
}
%%%%%%%%%%%%%%%%%%%%%
@@ -116,7 +116,7 @@
\prg_new_eq_conditional:NNn \baz:n \tl_if_blank:n { T , F }
\cs_if_eq:NNTF \baz:nT \tl_if_blank:nT { \TRUE } { \ERROR }
\cs_if_eq:NNTF \baz:nF \tl_if_blank:nF { \TRUE } { \ERROR }
- \cs_if_eq:NNTF \baz:nTF \tl_if_blank:nTF { \ERROR } { \FALSE }
+ \cs_if_eq:NNTF \baz:nTF \tl_if_blank:nTF { \TRUE } { \ERROR }
}
%%%%%%%%%%%%%%%%%%%%%
diff --git a/l3kernel/testfiles/m3basics002.tlg b/l3kernel/testfiles/m3basics002.tlg
index 95b79c494..c3bec1ebd 100644
--- a/l3kernel/testfiles/m3basics002.tlg
+++ b/l3kernel/testfiles/m3basics002.tlg
@@ -121,7 +121,10 @@ Defining \bar:nnnTF on line ...
Defining \bar_p:nnn on line ...
> \bar:nnnT=\long macro:#1#2#3->\prg_return_true: \exp_end: \use:n \use_none:n .
> \bar:nnnF=\long macro:#1#2#3->\prg_return_true: \exp_end: {}.
+Defining \bar:nT on line ...
+Defining \bar:nF on line ...
Defining \bar:nTF on line ...
+Defining \bar_p:n on line ...
============================================================
============================================================
TEST 7: prg_new_conditional with errors
@@ -146,13 +149,18 @@ TEST 8: prg_set_eq_conditional:NNn
============================================================
Defining \baz:nT on line ...
Defining \baz:nF on line ...
+Defining \baz:nTF on line ...
+Defining \baz_p:n on line ...
+TRUE
TRUE
TRUE
-FALSE
============================================================
============================================================
TEST 9: prg_set_eq_conditional:NNn with errors
============================================================
+Defining \my_if_in:nnT on line ...
+Defining \my_if_in:nnF on line ...
+Defining \my_if_in:nnTF on line ...
! LaTeX Error: Control sequence \tl_if_in_p:nn undefined.
For immediate help type H <return>.
...
@@ -161,12 +169,6 @@ This is a coding error.
LaTeX has been asked to use a control sequence '\tl_if_in_p:nn':
this has not been defined yet.
Defining \my_if_in_p:nn on line ...
-! LaTeX Error: Conditional form 't' for function '\my_if_in:nn' unknown.
-For immediate help type H <return>.
- ...
-l. ... }
-This is a coding error.
-LaTeX has been asked to define the conditional form 't' of the function '\my_if_in:nn', but only 'TF', 'T', 'F', and 'p' forms exist.
! LaTeX Error: Function '\foo' contains no ':'.
For immediate help type H <return>.
...
More information about the latex3-commits
mailing list.