[latex3-commits] [latex3/latex3] conditional-forms: Remove tracking expandablity for conditional generate (589141d0c)
github at latex-project.org
github at latex-project.org
Sun Nov 24 10:08:30 CET 2024
Repository : https://github.com/latex3/latex3
On branch : conditional-forms
Link : https://github.com/latex3/latex3/commit/589141d0c0aca8639f5c9d7c91550179661b9d85
>---------------------------------------------------------------
commit 589141d0c0aca8639f5c9d7c91550179661b9d85
Author: Joseph Wright <joseph at texdev.net>
Date: Tue Nov 19 16:04:57 2024 +0000
Remove tracking expandablity for conditional generate
Part of a fix for #1189.
>---------------------------------------------------------------
589141d0c0aca8639f5c9d7c91550179661b9d85
l3kernel/l3basics.dtx | 176 +++++++++++++++++--------------------
l3kernel/l3msg.dtx | 7 --
l3kernel/testfiles/m3basics002.lvt | 6 +-
l3kernel/testfiles/m3basics002.tlg | 15 ----
4 files changed, 82 insertions(+), 122 deletions(-)
diff --git a/l3kernel/l3basics.dtx b/l3kernel/l3basics.dtx
index 934bffb39..f4815d260 100644
--- a/l3kernel/l3basics.dtx
+++ b/l3kernel/l3basics.dtx
@@ -1949,38 +1949,37 @@
% \prg_gset_protected_conditional:Npnn,
% \prg_new_protected_conditional:Npnn
% }
-% \begin{macro}{\@@_generate_conditional_parm:NNNpnn}
+% \begin{macro}{\@@_generate_conditional_parm:NNpnn}
% The user functions for the types using parameter text from the
% programmer. The various functions only differ by which function is
% used for the assignment. For those |Npnn| type functions, we must
% grab the parameter text, reading everything up to a left brace
% before continuing. Then split the base function into name and
% signature, and feed \Arg{name} \Arg{signature} \meta{boolean}
-% \Arg{set~or~new} \Arg{maybe~protected} \Arg{parameters} |{TF,...}|
+% \Arg{set~or~new} \Arg{parameters} |{TF,...}|
% \Arg{code} to the auxiliary function responsible for defining all
% conditionals.
-% Note that |e| stands for expandable and |p| for protected.
% \begin{macrocode}
\cs_gset_protected:Npn \prg_set_conditional:Npnn
- { \@@_generate_conditional_parm:NNNpnn \cs_set:Npn e }
+ { \@@_generate_conditional_parm:NNpnn \cs_set:Npn }
\cs_gset_protected:Npn \prg_gset_conditional:Npnn
- { \@@_generate_conditional_parm:NNNpnn \cs_gset:Npn e }
+ { \@@_generate_conditional_parm:NNpnn \cs_gset:Npn }
\cs_gset_protected:Npn \prg_new_conditional:Npnn
- { \@@_generate_conditional_parm:NNNpnn \cs_new:Npn e }
+ { \@@_generate_conditional_parm:NNpnn \cs_new:Npn }
\cs_gset_protected:Npn \prg_set_protected_conditional:Npnn
- { \@@_generate_conditional_parm:NNNpnn \cs_set_protected:Npn p }
+ { \@@_generate_conditional_parm:NNpnn \cs_set_protected:Npn }
\cs_gset_protected:Npn \prg_gset_protected_conditional:Npnn
- { \@@_generate_conditional_parm:NNNpnn \cs_gset_protected:Npn p }
+ { \@@_generate_conditional_parm:NNpnn \cs_gset_protected:Npn }
\cs_gset_protected:Npn \prg_new_protected_conditional:Npnn
- { \@@_generate_conditional_parm:NNNpnn \cs_new_protected:Npn p }
-\cs_gset_protected:Npn \@@_generate_conditional_parm:NNNpnn #1#2#3#4#
+ { \@@_generate_conditional_parm:NNpnn \cs_new_protected:Npn }
+\cs_gset_protected:Npn \@@_generate_conditional_parm:NNpnn #1#2#3#
{
\use:e
{
- \@@_generate_conditional:nnNNNnnn
- \cs_split_function:N #3
+ \@@_generate_conditional:nnNNnnn
+ \cs_split_function:N #2
}
- #1 #2 {#4}
+ #1 {#3}
}
% \end{macrocode}
% \end{macro}
@@ -1997,8 +1996,8 @@
% }
% \begin{macro}
% {
-% \@@_generate_conditional_count:NNNnn ,
-% \@@_generate_conditional_count:nnNNNnn
+% \@@_generate_conditional_count:NNnn ,
+% \@@_generate_conditional_count:nnNNnn
% }
% The user functions for the types automatically inserting the correct
% parameter text based on the signature. The various functions only
@@ -2006,7 +2005,7 @@
% function into name and signature. The second auxiliary generates
% the parameter text from the number of letters in the signature.
% Then feed \Arg{name} \Arg{signature} \meta{boolean} \Arg{set~or~new}
-% \Arg{maybe~protected} \Arg{parameters} |{TF,...}| \Arg{code} to the
+% \Arg{parameters} |{TF,...}| \Arg{code} to the
% auxiliary function responsible for defining all conditionals. If
% the \meta{signature} has more than $9$ letters, the definition is
% aborted since \TeX{} macros have at most $9$ arguments. The
@@ -2014,30 +2013,30 @@
% later.
% \begin{macrocode}
\cs_gset_protected:Npn \prg_set_conditional:Nnn
- { \@@_generate_conditional_count:NNNnn \cs_set:Npn e }
+ { \@@_generate_conditional_count:NNnn \cs_set:Npn }
\cs_gset_protected:Npn \prg_gset_conditional:Nnn
- { \@@_generate_conditional_count:NNNnn \cs_set:Npn e }
+ { \@@_generate_conditional_count:NNnn \cs_set:Npn }
\cs_gset_protected:Npn \prg_new_conditional:Nnn
- { \@@_generate_conditional_count:NNNnn \cs_new:Npn e }
+ { \@@_generate_conditional_count:NNnn \cs_new:Npn }
\cs_gset_protected:Npn \prg_set_protected_conditional:Nnn
- { \@@_generate_conditional_count:NNNnn \cs_set_protected:Npn p }
+ { \@@_generate_conditional_count:NNnn \cs_set_protected:Npn }
\cs_gset_protected:Npn \prg_gset_protected_conditional:Nnn
- { \@@_generate_conditional_count:NNNnn \cs_gset_protected:Npn p }
+ { \@@_generate_conditional_count:NNnn \cs_gset_protected:Npn }
\cs_gset_protected:Npn \prg_new_protected_conditional:Nnn
- { \@@_generate_conditional_count:NNNnn \cs_new_protected:Npn p }
-\cs_gset_protected:Npn \@@_generate_conditional_count:NNNnn #1#2#3
+ { \@@_generate_conditional_count:NNnn \cs_new_protected:Npn }
+\cs_gset_protected:Npn \@@_generate_conditional_count:NNnn #1#2
{
\use:e
{
- \@@_generate_conditional_count:nnNNNnn
- \cs_split_function:N #3
+ \@@_generate_conditional_count:nnNNnn
+ \cs_split_function:N #2
}
- #1 #2
+ #1
}
-\cs_gset_protected:Npn \@@_generate_conditional_count:nnNNNnn #1#2#3#4#5
+\cs_gset_protected:Npn \@@_generate_conditional_count:nnNNnn #1#2#3#4
{
\__kernel_cs_parm_from_arg_count:nnF
- { \@@_generate_conditional:nnNNNnnn {#1} {#2} #3 #4 #5 }
+ { \@@_generate_conditional:nnNNnnn {#1} {#2} #3 #4 }
{ \tl_count:n {#2} }
{
\msg_error:nnee { kernel } { bad-number-of-arguments }
@@ -2052,8 +2051,8 @@
%
% \begin{macro}
% {
-% \@@_generate_conditional:nnNNNnnn,
-% \@@_generate_conditional:NNnnnnNw,
+% \@@_generate_conditional:nnNNnnn,
+% \@@_generate_conditional:NnnnnNw,
% \@@_generate_conditional_test:w,
% \@@_generate_conditional_fast:nw,
% }
@@ -2062,9 +2061,9 @@
% the base form of the conditional, which gives the name, signature
% and a boolean to signal whether or not there was a colon in the
% name. In the absence of a colon, we throw an error and don't define
-% any conditional. The fourth and fifth arguments build up the
-% defining function. The sixth is the parameters to use (possibly
-% empty), the seventh is the list of forms to define, the eighth is the
+% any conditional. The fourth arguments builds up the
+% defining function. The fifth is the parameters to use (possibly
+% empty), the sixth is the list of forms to define, the seventh is the
% replacement text which we will augment when defining the forms.
% The use of \cs{tl_to_str:n} makes the later loop more robust.
%
@@ -2073,9 +2072,9 @@
% we optimize this special case by calling
% \cs{@@_generate_conditional_fast:nw} \Arg{code}. This passes
% \cs{use_i:nn} instead of \cs{use_i_ii:nnn} to functions such as
-% \cs{@@_generate_p_form:wNNnnnnN}.
+% \cs{@@_generate_p_form:wNnnnnN}.
% \begin{macrocode}
-\cs_gset_protected:Npn \@@_generate_conditional:nnNNNnnn #1#2#3#4#5#6#7#8
+\cs_gset_protected:Npn \@@_generate_conditional:nnNNnnn #1#2#3#4#5#6#7
{
\if_meaning:w \c_false_bool #3
\msg_error:nne { kernel } { missing-colon }
@@ -2084,15 +2083,15 @@
\fi:
\use:e
{
- \exp_not:N \@@_generate_conditional:NNnnnnNw
- \exp_not:n { #4 #5 {#1} {#2} {#6} }
+ \exp_not:N \@@_generate_conditional:NnnnnNw
+ \exp_not:n { #4 {#1} {#2} {#5} }
\@@_generate_conditional_test:w
- #8 \s_@@_mark
+ #7 \s_@@_mark
\@@_generate_conditional_fast:nw
\prg_return_true: \else: \prg_return_false: \fi: \s_@@_mark
\use_none:n
- \exp_not:n { {#8} \use_i_ii:nnn }
- \tl_to_str:n {#7}
+ \exp_not:n { {#7} \use_i_ii:nnn }
+ \tl_to_str:n {#6}
\exp_not:n { , \q_@@_recursion_tail , \q_@@_recursion_stop }
}
}
@@ -2102,54 +2101,52 @@
\cs_gset:Npn \@@_generate_conditional_fast:nw #1#2 \exp_not:n #3
{ \exp_not:n { {#1} \use_i:nn } }
% \end{macrocode}
-% Looping through the list of desired forms. First are six arguments
-% and seventh is the form. Use the form to call the
+% Looping through the list of desired forms. First are five arguments
+% and sixth is the form. Use the form to call the
% correct type. If the form does not exist, the \cs{use:c}
% construction results in \tn{relax}, and the error message is
% displayed (unless the form is empty, to allow for |{T, , F}|),
% then \cs{use_none:nnnnnnnn} cleans up. Otherwise, the
% error message is removed by the variant form.
% \begin{macrocode}
-\cs_gset_protected:Npn \@@_generate_conditional:NNnnnnNw #1#2#3#4#5#6#7#8 ,
+\cs_gset_protected:Npn \@@_generate_conditional:NnnnnNw #1#2#3#4#5#6#7 ,
{
- \if_meaning:w \q_@@_recursion_tail #8
+ \if_meaning:w \q_@@_recursion_tail #7
\exp_after:wN \@@_use_none_delimit_by_q_recursion_stop:w
\fi:
- \use:c { @@_generate_ #8 _form:wNNnnnnN }
- \tl_if_empty:nF {#8}
+ \use:c { @@_generate_ #7 _form:wNnnnnN }
+ \tl_if_empty:nF {#7}
{
\msg_error:nnee
{ kernel } { conditional-form-unknown }
- {#8} { \token_to_str:c { #3 : #4 } }
+ {#7} { \token_to_str:c { #2 : #3 } }
}
\use_none:nnnnnnnn
\s_@@_stop
- #1 #2 {#3} {#4} {#5} {#6} #7
- \@@_generate_conditional:NNnnnnNw #1 #2 {#3} {#4} {#5} {#6} #7
+ #1 {#2} {#3} {#4} {#5} #6
+ \@@_generate_conditional:NnnnnNw #1 {#2} {#3} {#4} {#5} #6
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}
% {
-% \@@_generate_p_form:wNNnnnnN,
-% \@@_generate_TF_form:wNNnnnnN,
-% \@@_generate_T_form:wNNnnnnN,
-% \@@_generate_F_form:wNNnnnnN
+% \@@_generate_p_form:wNnnnnN,
+% \@@_generate_TF_form:wNnnnnN,
+% \@@_generate_T_form:wNnnnnN,
+% \@@_generate_F_form:wNnnnnN
% }
% \begin{macro}[EXP]{\@@_p_true:w, \@@_T_true:w, \@@_F_true:w, \@@_TF_true:w}
% How to generate the various forms. Those functions take the
-% following arguments: 1: junk, 2: \cs{cs_set:Npn} or similar, 3: |p|
-% (for protected conditionals) or |e|, 4: function name, 5: signature,
-% 6: parameter text, 7: replacement (possibly trimmed by
-% \cs{@@_generate_conditional_fast:nw}), 8: \cs{use_i_ii:nnn} or
+% following arguments: 1: junk, 2: \cs{cs_set:Npn} or similar,
+% 3: function name, 4: signature,
+% 5: parameter text, 6: replacement (possibly trimmed by
+% \cs{@@_generate_conditional_fast:nw}), 7: \cs{use_i_ii:nnn} or
% \cs{use_i:nn} (for \enquote{fast} conditionals). Remember that the
% logic-returning functions expect two arguments to be present after
% \cs{exp_end:}: notice the construction of the different variants
% relies on this, and that the |TF| and |F| variants will be slightly
-% faster than the |T| version. The |p| form is only valid for
-% expandable tests, we check for that by making sure that the second
-% argument is empty. For \enquote{fast} conditionals, |#7| has an
+% faster than the |T| version. For \enquote{fast} conditionals, |#7| has an
% extra \cs[no-index]{if_\ldots{}}. To optimize a bit further we
% don't use \cs{exp_after:wN} \cs{use_ii:nnn} and similar but instead use
% \cs{@@_TF_true:w} and similar to swap out the macro after \cs{fi:}. It would
@@ -2157,48 +2154,37 @@
% but if those are actually missing, the recovery from the runaway argument
% would not insert \cs{fi:} back, messing up nesting of conditionals.
% \begin{macrocode}
-\cs_gset_protected:Npn \@@_generate_p_form:wNNnnnnN
- #1 \s_@@_stop #2#3#4#5#6#7#8
+\cs_gset_protected:Npn \@@_generate_p_form:wNnnnnN
+ #1 \s_@@_stop #2#3#4#5#6#7
{
- \if_meaning:w e #3
- \exp_after:wN \use_i:nn
- \else:
- \exp_after:wN \use_ii:nn
- \fi:
- {
- #8
- { \exp_args:Nc #2 { #4 _p: #5 } #6 }
- { { #7 \exp_end: \c_true_bool \c_false_bool } }
- { #7 \@@_p_true:w \fi: \c_false_bool }
- }
- {
- \msg_error:nne { kernel } { protected-predicate }
- { \token_to_str:c { #4 _p: #5 } }
- }
+ #7
+ { \exp_args:Nc #2 { #3 _p: #4 } #5 }
+ { { #6 \exp_end: \c_true_bool \c_false_bool } }
+ { #6 \@@_p_true:w \fi: \c_false_bool }
}
-\cs_gset_protected:Npn \@@_generate_T_form:wNNnnnnN
- #1 \s_@@_stop #2#3#4#5#6#7#8
+\cs_gset_protected:Npn \@@_generate_T_form:wNnnnnN
+ #1 \s_@@_stop #2#3#4#5#6#7
{
- #8
- { \exp_args:Nc #2 { #4 : #5 T } #6 }
- { { #7 \exp_end: \use:n \use_none:n } }
- { #7 \@@_T_true:w \fi: \use_none:n }
+ #7
+ { \exp_args:Nc #2 { #3 : #4 T } #5 }
+ { { #6 \exp_end: \use:n \use_none:n } }
+ { #6 \@@_T_true:w \fi: \use_none:n }
}
-\cs_gset_protected:Npn \@@_generate_F_form:wNNnnnnN
- #1 \s_@@_stop #2#3#4#5#6#7#8
+\cs_gset_protected:Npn \@@_generate_F_form:wNnnnnN
+ #1 \s_@@_stop #2#3#4#5#6#7
{
- #8
- { \exp_args:Nc #2 { #4 : #5 F } #6 }
- { { #7 \exp_end: { } } }
- { #7 \@@_F_true:w \fi: \use:n }
+ #7
+ { \exp_args:Nc #2 { #3 : #4 F } #5 }
+ { { #6 \exp_end: { } } }
+ { #6 \@@_F_true:w \fi: \use:n }
}
-\cs_gset_protected:Npn \@@_generate_TF_form:wNNnnnnN
- #1 \s_@@_stop #2#3#4#5#6#7#8
+\cs_gset_protected:Npn \@@_generate_TF_form:wNnnnnN
+ #1 \s_@@_stop #2#3#4#5#6#7
{
- #8
- { \exp_args:Nc #2 { #4 : #5 TF } #6 }
- { { #7 \exp_end: } }
- { #7 \@@_TF_true:w \fi: \use_ii:nn }
+ #7
+ { \exp_args:Nc #2 { #3 : #4 TF } #5 }
+ { { #6 \exp_end: } }
+ { #6 \@@_TF_true:w \fi: \use_ii:nn }
}
\cs_gset:Npn \@@_p_true:w \fi: \c_false_bool { \fi: \c_true_bool }
\cs_gset:Npn \@@_T_true:w \fi: \use_none:n { \fi: \use:n }
diff --git a/l3kernel/l3msg.dtx b/l3kernel/l3msg.dtx
index 68058724e..0373f6837 100644
--- a/l3kernel/l3msg.dtx
+++ b/l3kernel/l3msg.dtx
@@ -2079,13 +2079,6 @@
An~attempt~was~made~to~access~or~store~data~at~position~#2~of~the~
array~'#1',~but~this~array~has~entries~at~positions~from~1~to~#3.
}
-\msg_new:nnnn { kernel } { protected-predicate }
- { Predicate~'#1'~must~be~expandable. }
- {
- \c_@@_coding_error_text_tl
- LaTeX~has~been~asked~to~define~'#1'~as~a~protected~predicate.~
- Only~expandable~tests~can~have~a~predicate~version.
- }
\msg_new:nnn { kernel } { randint-backward-range }
{ Wrong~order~of~bounds~in~\iow_char:N\\int_rand:nn{#1}{#2}. }
\msg_new:nnnn { kernel } { conditional-form-unknown }
diff --git a/l3kernel/testfiles/m3basics002.lvt b/l3kernel/testfiles/m3basics002.lvt
index ef11f113d..8d83d15db 100644
--- a/l3kernel/testfiles/m3basics002.lvt
+++ b/l3kernel/testfiles/m3basics002.lvt
@@ -87,7 +87,7 @@
%%%%%%%%%%%%%%%%%%%%%
\TEST { prg_new_conditional:Nnn }
{
- \prg_new_protected_conditional:Nnn \foo:nnn { T , , F , TF , }
+ \prg_new_protected_conditional:Nnn \foo:nnn { T , F , TF }
{ \tl_show:n { #1 #2 #3 } \prg_return_true: }
\cs_log:N \foo:nnnT
\cs_log:N \foo:nnnF
@@ -108,10 +108,6 @@
\prg_new_conditional:Nnn \foo:nnnnnnnnnnnn { TF }
{ \prg_return_true: }
\cs_log:N \foo:nnnnnnnnnnnnTF
- \prg_new_protected_conditional:Npnn \baz:n #1 { p , xx , TF }
- { \prg_return_true: }
- \cs_log:N \baz_p:n
- \cs_log:N \baz:nTF
}
%%%%%%%%%%%%%%%%%%%%%
diff --git a/l3kernel/testfiles/m3basics002.tlg b/l3kernel/testfiles/m3basics002.tlg
index 01d8c92fe..9c534d21d 100644
--- a/l3kernel/testfiles/m3basics002.tlg
+++ b/l3kernel/testfiles/m3basics002.tlg
@@ -138,21 +138,6 @@ l. ... }
This is a coding error.
LaTeX has been asked to define a function '\foo:nnnnnnnnnnnn' with 12 arguments. TeX allows between 0 and 9 arguments for a single function.
> \foo:nnnnnnnnnnnnTF=undefined.
-! LaTeX Error: Predicate '\baz_p:n' must be expandable.
-For immediate help type H <return>.
- ...
-l. ... }
-This is a coding error.
-LaTeX has been asked to define '\baz_p:n' as a protected predicate. Only expandable tests can have a predicate version.
-! LaTeX Error: Conditional form 'xx' for function '\baz:n' unknown.
-For immediate help type H <return>.
- ...
-l. ... }
-This is a coding error.
-LaTeX has been asked to define the conditional form 'xx' of the function '\baz:n', but only 'TF', 'T', 'F', and 'p' forms exist.
-Defining \baz:nTF on line ...
-> \baz_p:n=\relax.
-> \baz:nTF=\protected\long macro:#1->\prg_return_true: \exp_end: .
============================================================
============================================================
TEST 8: prg_set_eq_conditional:NNn
More information about the latex3-commits
mailing list.