[latex3-commits] [git/LaTeX3-latex3-latex3] bool_case: Change \bool_case to \bool_case_true/false (741ec47)

Bruno Le Floch bruno at le-floch.fr
Wed Feb 27 22:06:53 CET 2019


Repository : https://github.com/latex3/latex3
On branch  : bool_case
Link       : https://github.com/latex3/latex3/commit/741ec471d594af582161ffd5766a2ff9dbb5ada1

>---------------------------------------------------------------

commit 741ec471d594af582161ffd5766a2ff9dbb5ada1
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Wed Feb 27 22:06:53 2019 +0100

    Change \bool_case to \bool_case_true/false


>---------------------------------------------------------------

741ec471d594af582161ffd5766a2ff9dbb5ada1
 l3kernel/CHANGELOG.md                   |    4 ++
 l3kernel/l3candidates.dtx               |   73 ++++++++++++++++++++-----------
 l3kernel/testfiles/m3expl001.luatex.tlg |   17 ++++---
 l3kernel/testfiles/m3expl001.ptex.tlg   |   17 ++++---
 l3kernel/testfiles/m3expl001.tlg        |   17 ++++---
 l3kernel/testfiles/m3expl001.uptex.tlg  |   17 ++++---
 l3kernel/testfiles/m3expl001.xetex.tlg  |   17 ++++---
 l3kernel/testfiles/m3expl003.luatex.tlg |   17 ++++---
 l3kernel/testfiles/m3expl003.ptex.tlg   |   17 ++++---
 l3kernel/testfiles/m3expl003.tlg        |   17 ++++---
 l3kernel/testfiles/m3expl003.uptex.tlg  |   17 ++++---
 l3kernel/testfiles/m3expl003.xetex.tlg  |   17 ++++---
 l3kernel/testfiles/m3prg005.lvt         |   22 +++++++++-
 l3kernel/testfiles/m3prg005.tlg         |    2 +
 14 files changed, 183 insertions(+), 88 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index feb0de2..b3a5502 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,10 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Added
+
+- `\bool_case_true:n(TF)` and `\bool_case_false:n(TF)`
+
 ## [2019-02-03]
 
 ### Added
diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index 1418b3b..8b24e22 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -634,9 +634,10 @@
 %   conversely: sets it to the inverse of its current value.
 % \end{function}
 %
-% \begin{function}[added = 2019-02-10, EXP, noTF]{\bool_case:n}
+% \begin{function}[added = 2019-02-10, EXP, noTF]
+%   {\bool_case_true:n, \bool_case_false:n}
 %   \begin{syntax}
-%     \cs{bool_case:nTF} \\
+%     \cs{bool_case_true:nTF} \\
 %     ~~|{| \\
 %     ~~~~\Arg{boolexpr case_1} \Arg{code case_1} \\
 %     ~~~~\Arg{boolexpr case_2} \Arg{code case_2} \\
@@ -646,17 +647,17 @@
 %     ~~\Arg{true code}
 %     ~~\Arg{false code}
 %   \end{syntax}
-%   This function evaluates in turn each of the
-%   \meta{boolean expression cases}. If it is true then the
-%   associated \meta{code} is left in the input stream
-%   and other cases are discarded. If any of the
-%   cases is true, the \meta{true code} is also inserted into the
-%   input stream (after the code for the appropriate case), while if none
-%   match then the \meta{false code} is inserted. The function
-%   \cs{bool_case:n}, which does nothing if there is no match, is also
-%   available. For example
+%   Evaluates in turn each of the \meta{boolean expression cases} until
+%   the first one that evaluates to \texttt{true} or to \texttt{false},
+%   for \cs{bool_case_true:n} and \cs{bool_case_false:n}, respectively.
+%   The \meta{code} associated to this first case is left in the input
+%   stream, followed by the \meta{true code}, and other cases are
+%   discarded.  If none of the cases match then only the \meta{false
+%   code} is inserted. The functions \cs{bool_case_true:n} and
+%   \cs{bool_case_false:n}, which do nothing if there is no match, are
+%   also available. For example
 %   \begin{verbatim}
-%     \bool_case:nF
+%     \bool_case_true:nF
 %       {
 %         { \dim_compare_p:n { \l__mypkg_wd_dim <= 10pt } }
 %             { Fits }
@@ -2554,24 +2555,44 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}[EXP, noTF]{\bool_case:n}
-% \begin{macro}{\@@_case:nTF}
-% \begin{macro}{\@@_case:w, \@@_case_end:nw}
+% \begin{macro}[EXP, noTF]{\bool_case_true:n, \bool_case_false:n}
+% \begin{macro}{\@@_case:NnTF}
+% \begin{macro}{\@@_case_true:w, \@@_case_false:w, \@@_case_end:nw}
 %   For boolean cases the overall idea is the same as for
-%   \cs{tl_case:nn(TF)} as described in \pkg{l3tl}, but with one fewer
-%   argument to track.
-%    \begin{macrocode}
-\cs_new:Npn \bool_case:nTF { \exp:w \@@_case:nTF }
-\cs_new:Npn \bool_case:nT #1#2 { \exp:w \@@_case:nTF {#1} {#2} { } }
-\cs_new:Npn \bool_case:nF #1 { \exp:w \@@_case:nTF {#1} { } }
-\cs_new:Npn \bool_case:n #1 { \exp:w \@@_case:nTF {#1} { } { } }
-\cs_new:Npn \@@_case:nTF #1#2#3
-  { \@@_case:w #1 \c_true_bool { } \q_mark {#2} \q_mark {#3} \q_stop }
-\cs_new:Npn \@@_case:w #1#2
+%   \cs{tl_case:nn(TF)} as described in \pkg{l3tl}.
+%    \begin{macrocode}
+\cs_new:Npn \bool_case_true:nTF
+  { \exp:w \@@_case:NnTF \c_true_bool }
+\cs_new:Npn \bool_case_true:nT #1#2
+  { \exp:w \@@_case:NnTF \c_true_bool {#1} {#2} { } }
+\cs_new:Npn \bool_case_true:nF #1
+  { \exp:w \@@_case:NnTF \c_true_bool {#1} { } }
+\cs_new:Npn \bool_case_true:n #1
+  { \exp:w \@@_case:NnTF \c_true_bool {#1} { } { } }
+\cs_new:Npn \bool_case_false:nTF
+  { \exp:w \@@_case:NnTF \c_false_bool }
+\cs_new:Npn \bool_case_false:nT #1#2
+  { \exp:w \@@_case:NnTF \c_false_bool {#1} {#2} { } }
+\cs_new:Npn \bool_case_false:nF #1
+  { \exp:w \@@_case:NnTF \c_false_bool {#1} { } }
+\cs_new:Npn \bool_case_false:n #1
+  { \exp:w \@@_case:NnTF \c_false_bool {#1} { } { } }
+\cs_new:Npn \@@_case:NnTF #1#2#3#4
+  {
+    \bool_if:NTF #1 \@@_case_true:w \@@_case_false:w
+    #2 #1 { } \q_mark {#3} \q_mark {#4} \q_stop
+  }
+\cs_new:Npn \@@_case_true:w #1#2
+  {
+    \bool_if:nTF {#1}
+      { \@@_case_end:nw {#2} }
+      { \@@_case_true:w }
+  }
+\cs_new:Npn \@@_case_false:w #1#2
   {
     \bool_if:nTF {#1}
+      { \@@_case_false:w }
       { \@@_case_end:nw {#2} }
-      { \@@_case:w }
   }
 \cs_new:Npn \@@_case_end:nw #1#2#3 \q_mark #4#5 \q_stop
   { \exp_end: #1 #4 }
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index df4d1a1..0b4477a 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -5966,12 +5966,17 @@ Defining \bool_set_inverse:N on line ...
 Defining \bool_set_inverse:c on line ...
 Defining \bool_gset_inverse:N on line ...
 Defining \bool_gset_inverse:c on line ...
-Defining \bool_case:nTF on line ...
-Defining \bool_case:nT on line ...
-Defining \bool_case:nF on line ...
-Defining \bool_case:n on line ...
-Defining \__bool_case:nTF on line ...
-Defining \__bool_case:w on line ...
+Defining \bool_case_true:nTF on line ...
+Defining \bool_case_true:nT on line ...
+Defining \bool_case_true:nF on line ...
+Defining \bool_case_true:n on line ...
+Defining \bool_case_false:nTF on line ...
+Defining \bool_case_false:nT on line ...
+Defining \bool_case_false:nF on line ...
+Defining \bool_case_false:n on line ...
+Defining \__bool_case:NnTF on line ...
+Defining \__bool_case_true:w on line ...
+Defining \__bool_case_false:w on line ...
 Defining \__bool_case_end:nw on line ...
 Defining \prop_count:N on line ...
 Defining \__prop_count:nn on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index 4dd34d6..216d807 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -5999,12 +5999,17 @@ Defining \bool_set_inverse:N on line ...
 Defining \bool_set_inverse:c on line ...
 Defining \bool_gset_inverse:N on line ...
 Defining \bool_gset_inverse:c on line ...
-Defining \bool_case:nTF on line ...
-Defining \bool_case:nT on line ...
-Defining \bool_case:nF on line ...
-Defining \bool_case:n on line ...
-Defining \__bool_case:nTF on line ...
-Defining \__bool_case:w on line ...
+Defining \bool_case_true:nTF on line ...
+Defining \bool_case_true:nT on line ...
+Defining \bool_case_true:nF on line ...
+Defining \bool_case_true:n on line ...
+Defining \bool_case_false:nTF on line ...
+Defining \bool_case_false:nT on line ...
+Defining \bool_case_false:nF on line ...
+Defining \bool_case_false:n on line ...
+Defining \__bool_case:NnTF on line ...
+Defining \__bool_case_true:w on line ...
+Defining \__bool_case_false:w on line ...
 Defining \__bool_case_end:nw on line ...
 Defining \prop_count:N on line ...
 Defining \__prop_count:nn on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index f7f2f5c..4d266c9 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -5999,12 +5999,17 @@ Defining \bool_set_inverse:N on line ...
 Defining \bool_set_inverse:c on line ...
 Defining \bool_gset_inverse:N on line ...
 Defining \bool_gset_inverse:c on line ...
-Defining \bool_case:nTF on line ...
-Defining \bool_case:nT on line ...
-Defining \bool_case:nF on line ...
-Defining \bool_case:n on line ...
-Defining \__bool_case:nTF on line ...
-Defining \__bool_case:w on line ...
+Defining \bool_case_true:nTF on line ...
+Defining \bool_case_true:nT on line ...
+Defining \bool_case_true:nF on line ...
+Defining \bool_case_true:n on line ...
+Defining \bool_case_false:nTF on line ...
+Defining \bool_case_false:nT on line ...
+Defining \bool_case_false:nF on line ...
+Defining \bool_case_false:n on line ...
+Defining \__bool_case:NnTF on line ...
+Defining \__bool_case_true:w on line ...
+Defining \__bool_case_false:w on line ...
 Defining \__bool_case_end:nw on line ...
 Defining \prop_count:N on line ...
 Defining \__prop_count:nn on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index abdd600..6199744 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -5996,12 +5996,17 @@ Defining \bool_set_inverse:N on line ...
 Defining \bool_set_inverse:c on line ...
 Defining \bool_gset_inverse:N on line ...
 Defining \bool_gset_inverse:c on line ...
-Defining \bool_case:nTF on line ...
-Defining \bool_case:nT on line ...
-Defining \bool_case:nF on line ...
-Defining \bool_case:n on line ...
-Defining \__bool_case:nTF on line ...
-Defining \__bool_case:w on line ...
+Defining \bool_case_true:nTF on line ...
+Defining \bool_case_true:nT on line ...
+Defining \bool_case_true:nF on line ...
+Defining \bool_case_true:n on line ...
+Defining \bool_case_false:nTF on line ...
+Defining \bool_case_false:nT on line ...
+Defining \bool_case_false:nF on line ...
+Defining \bool_case_false:n on line ...
+Defining \__bool_case:NnTF on line ...
+Defining \__bool_case_true:w on line ...
+Defining \__bool_case_false:w on line ...
 Defining \__bool_case_end:nw on line ...
 Defining \prop_count:N on line ...
 Defining \__prop_count:nn on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index cff283d..7fc590d 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -5977,12 +5977,17 @@ Defining \bool_set_inverse:N on line ...
 Defining \bool_set_inverse:c on line ...
 Defining \bool_gset_inverse:N on line ...
 Defining \bool_gset_inverse:c on line ...
-Defining \bool_case:nTF on line ...
-Defining \bool_case:nT on line ...
-Defining \bool_case:nF on line ...
-Defining \bool_case:n on line ...
-Defining \__bool_case:nTF on line ...
-Defining \__bool_case:w on line ...
+Defining \bool_case_true:nTF on line ...
+Defining \bool_case_true:nT on line ...
+Defining \bool_case_true:nF on line ...
+Defining \bool_case_true:n on line ...
+Defining \bool_case_false:nTF on line ...
+Defining \bool_case_false:nT on line ...
+Defining \bool_case_false:nF on line ...
+Defining \bool_case_false:n on line ...
+Defining \__bool_case:NnTF on line ...
+Defining \__bool_case_true:w on line ...
+Defining \__bool_case_false:w on line ...
 Defining \__bool_case_end:nw on line ...
 Defining \prop_count:N on line ...
 Defining \__prop_count:nn on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index df4d1a1..0b4477a 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -5966,12 +5966,17 @@ Defining \bool_set_inverse:N on line ...
 Defining \bool_set_inverse:c on line ...
 Defining \bool_gset_inverse:N on line ...
 Defining \bool_gset_inverse:c on line ...
-Defining \bool_case:nTF on line ...
-Defining \bool_case:nT on line ...
-Defining \bool_case:nF on line ...
-Defining \bool_case:n on line ...
-Defining \__bool_case:nTF on line ...
-Defining \__bool_case:w on line ...
+Defining \bool_case_true:nTF on line ...
+Defining \bool_case_true:nT on line ...
+Defining \bool_case_true:nF on line ...
+Defining \bool_case_true:n on line ...
+Defining \bool_case_false:nTF on line ...
+Defining \bool_case_false:nT on line ...
+Defining \bool_case_false:nF on line ...
+Defining \bool_case_false:n on line ...
+Defining \__bool_case:NnTF on line ...
+Defining \__bool_case_true:w on line ...
+Defining \__bool_case_false:w on line ...
 Defining \__bool_case_end:nw on line ...
 Defining \prop_count:N on line ...
 Defining \__prop_count:nn on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index 4dd34d6..216d807 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -5999,12 +5999,17 @@ Defining \bool_set_inverse:N on line ...
 Defining \bool_set_inverse:c on line ...
 Defining \bool_gset_inverse:N on line ...
 Defining \bool_gset_inverse:c on line ...
-Defining \bool_case:nTF on line ...
-Defining \bool_case:nT on line ...
-Defining \bool_case:nF on line ...
-Defining \bool_case:n on line ...
-Defining \__bool_case:nTF on line ...
-Defining \__bool_case:w on line ...
+Defining \bool_case_true:nTF on line ...
+Defining \bool_case_true:nT on line ...
+Defining \bool_case_true:nF on line ...
+Defining \bool_case_true:n on line ...
+Defining \bool_case_false:nTF on line ...
+Defining \bool_case_false:nT on line ...
+Defining \bool_case_false:nF on line ...
+Defining \bool_case_false:n on line ...
+Defining \__bool_case:NnTF on line ...
+Defining \__bool_case_true:w on line ...
+Defining \__bool_case_false:w on line ...
 Defining \__bool_case_end:nw on line ...
 Defining \prop_count:N on line ...
 Defining \__prop_count:nn on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index f7f2f5c..4d266c9 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -5999,12 +5999,17 @@ Defining \bool_set_inverse:N on line ...
 Defining \bool_set_inverse:c on line ...
 Defining \bool_gset_inverse:N on line ...
 Defining \bool_gset_inverse:c on line ...
-Defining \bool_case:nTF on line ...
-Defining \bool_case:nT on line ...
-Defining \bool_case:nF on line ...
-Defining \bool_case:n on line ...
-Defining \__bool_case:nTF on line ...
-Defining \__bool_case:w on line ...
+Defining \bool_case_true:nTF on line ...
+Defining \bool_case_true:nT on line ...
+Defining \bool_case_true:nF on line ...
+Defining \bool_case_true:n on line ...
+Defining \bool_case_false:nTF on line ...
+Defining \bool_case_false:nT on line ...
+Defining \bool_case_false:nF on line ...
+Defining \bool_case_false:n on line ...
+Defining \__bool_case:NnTF on line ...
+Defining \__bool_case_true:w on line ...
+Defining \__bool_case_false:w on line ...
 Defining \__bool_case_end:nw on line ...
 Defining \prop_count:N on line ...
 Defining \__prop_count:nn on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index abdd600..6199744 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -5996,12 +5996,17 @@ Defining \bool_set_inverse:N on line ...
 Defining \bool_set_inverse:c on line ...
 Defining \bool_gset_inverse:N on line ...
 Defining \bool_gset_inverse:c on line ...
-Defining \bool_case:nTF on line ...
-Defining \bool_case:nT on line ...
-Defining \bool_case:nF on line ...
-Defining \bool_case:n on line ...
-Defining \__bool_case:nTF on line ...
-Defining \__bool_case:w on line ...
+Defining \bool_case_true:nTF on line ...
+Defining \bool_case_true:nT on line ...
+Defining \bool_case_true:nF on line ...
+Defining \bool_case_true:n on line ...
+Defining \bool_case_false:nTF on line ...
+Defining \bool_case_false:nT on line ...
+Defining \bool_case_false:nF on line ...
+Defining \bool_case_false:n on line ...
+Defining \__bool_case:NnTF on line ...
+Defining \__bool_case_true:w on line ...
+Defining \__bool_case_false:w on line ...
 Defining \__bool_case_end:nw on line ...
 Defining \prop_count:N on line ...
 Defining \__prop_count:nn on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index cff283d..7fc590d 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -5977,12 +5977,17 @@ Defining \bool_set_inverse:N on line ...
 Defining \bool_set_inverse:c on line ...
 Defining \bool_gset_inverse:N on line ...
 Defining \bool_gset_inverse:c on line ...
-Defining \bool_case:nTF on line ...
-Defining \bool_case:nT on line ...
-Defining \bool_case:nF on line ...
-Defining \bool_case:n on line ...
-Defining \__bool_case:nTF on line ...
-Defining \__bool_case:w on line ...
+Defining \bool_case_true:nTF on line ...
+Defining \bool_case_true:nT on line ...
+Defining \bool_case_true:nF on line ...
+Defining \bool_case_true:n on line ...
+Defining \bool_case_false:nTF on line ...
+Defining \bool_case_false:nT on line ...
+Defining \bool_case_false:nF on line ...
+Defining \bool_case_false:n on line ...
+Defining \__bool_case:NnTF on line ...
+Defining \__bool_case_true:w on line ...
+Defining \__bool_case_false:w on line ...
 Defining \__bool_case_end:nw on line ...
 Defining \prop_count:N on line ...
 Defining \__prop_count:nn on line ...
diff --git a/l3kernel/testfiles/m3prg005.lvt b/l3kernel/testfiles/m3prg005.lvt
index 71530b2..f483862 100644
--- a/l3kernel/testfiles/m3prg005.lvt
+++ b/l3kernel/testfiles/m3prg005.lvt
@@ -73,7 +73,7 @@
 
 \TESTEXP { bool_case }
   {
-    \bool_case:nTF
+    \bool_case_true:nTF
       {
         { \int_compare_p:n { 1 > 2 } } { \ERROR }
         { \dim_compare_p:n { 10pt < 20pt } } { \TRUE }
@@ -82,7 +82,7 @@
       { \TRUE }
       { \ERROR }
     \NEWLINE
-    \bool_case:nTF
+    \bool_case_true:nTF
       {
         { \int_compare_p:n { 1 > 2 } } { \ERROR }
         { \dim_compare_p:n { 10pt < 20pt } && \c_false_bool } { \ERROR }
@@ -91,6 +91,24 @@
       { \ERROR }
       { \FALSE }
     \NEWLINE
+    \bool_case_false:nTF
+      {
+        { \int_compare_p:n { 1 < 2 } } { \ERROR }
+        { \dim_compare_p:n { 10pt > 20pt } } { \TRUE }
+        \ERROR \ERROR
+      }
+      { \TRUE }
+      { \ERROR }
+    \NEWLINE
+    \bool_case_false:nTF
+      {
+        { \int_compare_p:n { 1 < 2 } } { \ERROR }
+        { \dim_compare_p:n { 10pt > 20pt } || \c_true_bool } { \ERROR }
+        { \c_true_bool } { \ERROR }
+      }
+      { \ERROR }
+      { \FALSE }
+    \NEWLINE
   }
 
 \END
diff --git a/l3kernel/testfiles/m3prg005.tlg b/l3kernel/testfiles/m3prg005.tlg
index 32975a8..7791e05 100644
--- a/l3kernel/testfiles/m3prg005.tlg
+++ b/l3kernel/testfiles/m3prg005.tlg
@@ -54,4 +54,6 @@ TEST 5: bool_case
 ============================================================
 TRUETRUE
 FALSE
+TRUETRUE
+FALSE
 ============================================================





More information about the latex3-commits mailing list