[latex3-commits] [git/LaTeX3-latex3-latex3] master: pre-expand some internal functions (e73f772b0)

Bruno Le Floch blflatex at gmail.com
Tue Oct 27 09:11:58 CET 2020


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/e73f772b00917b4a44a178532d2f626fb618caa8

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

commit e73f772b00917b4a44a178532d2f626fb618caa8
Author: Jonathan Spratte <jspratte at yahoo.de>
Date:   Sat Oct 3 21:14:16 2020 +0200

    pre-expand some internal functions


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

e73f772b00917b4a44a178532d2f626fb618caa8
 l3kernel/l3tl.dtx | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/l3kernel/l3tl.dtx b/l3kernel/l3tl.dtx
index c5a2bda6f..235b56944 100644
--- a/l3kernel/l3tl.dtx
+++ b/l3kernel/l3tl.dtx
@@ -3170,19 +3170,8 @@
 % \begin{macro}[EXP]{\@@_use_none_delimit_by_q_act_stop:w}
 %   To help control the expansion, \cs{@@_act:NNNnn} should always
 %   be proceeded by \cs{exp:w} and ends by producing \cs{exp_end:}
-%   once the result has been obtained. Then loop over tokens,
-%   groups, and spaces in |#5|. |{\q_@@_act_stop}| serves as the end of token
-%   list marker, the |?| after it avoids losing outer braces. The result is
-%   stored as an argument for the dummy function \cs{@@_act_result:n}.
-%    \begin{macrocode}
-\cs_new:Npn \@@_act:NNNnn #1#2#3#4#5
-  {
-    \group_align_safe_begin:
-    \@@_act_loop:w #5 {\q_@@_act_stop} ? \q_@@_act_stop
-    {#4} #1 #3 #2
-    \@@_act_result:n { }
-  }
-%    \end{macrocode}
+%   once the result has been obtained. This way no internal token of it can be
+%   accidentally end up in the input stream.
 %   Because \cs{q_@@_act_stop} can't appear without braces around it in the
 %   argument~|#1| of \cs{@@_act_loop:w}, we can use this marker to set up a fast
 %   test for leading spaces.
@@ -3259,6 +3248,19 @@
     {#2} #3 #4
   }
 %    \end{macrocode}
+%   \cs{@@_act:NNNnn} loops over tokens, groups, and spaces in |#5|.
+%   |{\q_@@_act_stop}| serves as the end of token list marker, the |?| after it
+%   avoids losing outer braces. The result is stored as an argument for the
+%   dummy function \cs{@@_act_result:n}.
+%    \begin{macrocode}
+\exp_args:Nno \use:n { \cs_new:Npn \@@_act:NNNnn #1#2#3#4#5 }
+  {
+    \exp_after:wN \group_align_safe_begin:
+    \@@_act_loop:w #5 {\q_@@_act_stop} ? \q_@@_act_stop
+    {#4} #1 #3 #2
+    \@@_act_result:n { }
+  }
+%    \end{macrocode}
 %   Typically, the output is done to the right of what was already output,
 %   using \cs{@@_act_output:n}, but for the \cs{@@_act_reverse} functions,
 %   it should be done to the left.
@@ -3290,11 +3292,11 @@
 %   this is needed by \cs{@@_act:NNNnn} when changing case (to record
 %   which direction the change is in), but not when reversing the tokens.
 %    \begin{macrocode}
-\cs_new:Npn \tl_reverse:n #1
+\exp_args:Nno \use:n { \cs_new:Npn \tl_reverse:n #1 }
   {
-    \__kernel_exp_not:w \exp_after:wN
+    \exp_after:wN \__kernel_exp_not:w \exp_after:wN \exp_after:wN \exp_after:wN
       {
-        \exp:w
+        \exp_after:wN \exp:w
         \@@_act:NNNnn
           \@@_reverse_normal:nN
           \@@_reverse_group_preserve:nn
@@ -3304,8 +3306,8 @@
       }
   }
 \cs_generate_variant:Nn \tl_reverse:n { o , V }
-\cs_new:Npn \@@_reverse_normal:nN #1#2
-  { \@@_act_reverse_output:n {#2} }
+\cs_new:Npn \@@_reverse_normal:nN #1
+  { \@@_act_reverse_output:n }
 \cs_new:Npn \@@_reverse_group_preserve:nn #1#2
   { \@@_act_reverse_output:n { {#2} } }
 \cs_new:Npn \@@_reverse_space:n #1





More information about the latex3-commits mailing list.